Date and Time Fields - danmarksmiljoeportal/rotter GitHub Wiki
Date and Time Fields
There are many fields in the system, where the concept of a date does not involve any specific time of day and where the date will be the same regardless of timezone in which the date is referred to. For historical reasons, we have continued referring to these dates with a complete date and time reference including a timezone, but in the code we only care about the date part.
In other words, the following datetime samples will all mean "2024-11-27"
- '2024-11-27T03:44:12.539Z'
- '2024-11-27T00:44:12.539'
- '2024-11-27T23:44:12.539'
Whatever comes after the date is ignored.
For now, we only need to consider the date part of the datetime value for the following attributes in the REST API:
- RatOccurrence
- NotifiedDate
- CompletedDate
- FollowUpDates
- PoisonUsed.Date
- PoisonReturned.Date
- LatestExtermination
- SecurityScheme
- StartDate
- ExpiryDate
- PropertyInspection
Technical notes:
For a future version we will consider only receiving and sending the date part for these attributes. For now, developers will have to handle the above logic in their code. So to sum up:
- API Post Requests still accept the datetime value but will remove the time part of datetime value
- Api Get Requests will return full datetime fields but will consider only the date part. Even if we return in output objects a time part, this part should be ignored. It is simply a relic from older versions of the system. Until then, we still accept the DateTime value and still return the exact time you provided to us in the api get request.
- "completedDate": "2024-11-26T00:00:00"
- "completedDate": "2024-11-26T01:00:00Z"
- "completedDate": "2024-11-26T02:00:00.000Z"
- As it is the date we want to display and as we don't consider the timezone or any other factors; you should not convert the date from fx Danish timezone to UTC as it will cause the date to be misunderstood in other systems even if it seems correct in your system.
Considerations for a future version:
Request of api will still accept the datetime value (format above) as well as date only also but will remove the time part of datetime values in responses.
- Example:
Api POST RatOccurrence with request
{ ... "notifiedDate": "2024-11-26T05:00:00Z", "completedDate": "2024-11-26T01:12:00.000Z", ... }
Will become the object below in our system
{ ... "notifiedDate": "2024-11-26", "completedDate": "2024-11-26", ... }
The api GET RatOccurrence/{id} will return
{ ... "notifiedDate": "2024-11-26T00:00:00Z", "completedDate": "2024-11-26T00:00:00Z", ... }
- List API Impact
- Api POST
RatOccurrenceand PUTRatOccurrence/{id}- NotifiedDate
- CompletedDate
- FollowUpDates
- PoisonUsed.Date
- PoisonReturned.Date
- Api POST
RatOccurrence/Search- NotifiedDateFrom
- NotifiedDateTo
- CompletedDateFrom
- CompletedDateTo
- Api POST
SecuritySchemeand PUTSecurityScheme/{id}- StartDate
- ExpiryDate
- PropertyInspection
- Api POST
SecurityScheme/Mass- StartDate
- ExpiryDate
- PropertyInspection
- Api PUT
SecurityScheme/Mass- ExpiryDate
- Api GET
SecurityScheme- StartDateFrom
- StartDateTo
- ExpiryDateFrom
- ExpiryDateTo
- Api POST