Supporting Date Formats
Name | Format | Example |
---|---|---|
Date | YYYY-MM-DD |
2022-10-23 |
Time | hh:mm:ss hh:mm |
09:54:59 09:54 |
DateTime | YYYY-MM-DDThh:mm:ss |
2022-10-23T09:54:59 |
DateTimeWithTimeZone | YYYY-MM-DDThh:mm:ssTZD |
2022-10-23T09:54:59+14:00[Pacific/Kiritimati] |
Representing dates in an REST API is a common but often not well-thought-out functionality. There are two generally accepted date formats for API’s. The two date formats are,
- UTC Epoch format
- ISO 8601 format
The Travlinq will use ISO 8601 format
.
ISO 8601 format
The ISO 8601 standard is an International Standard for the representation of dates and times. This format contains date, time, and the offset from UTC, as well as the T character that designates the start of the time, for example, 2023-05-06T12:30:22-03:00. The pattern for this date and time format is YYYY-MM-DDThh:mm:ss.sTZD
. It is recommended to use the ISO-8601 format for representing the date and time in RESTful web APIs.
The formats for an ISO8601 date are as follows:
- Year: YYYY (2023)
- Year and month: YYYY-MM (2023-05)
- Complete date: YYYY-MM-DD (2023-05-22)
- Complete date plus hours and minutes: YYYY-MM-DDThh:mmTZD (2023-05-22T17:00+01:00)
- Complete date plus hours, minutes, and seconds: YYYY-MM-DDThh: mm:ssTZD (2023-05-22T17:00:25+01:00)
- Complete date plus hours, minutes, seconds, and a decimal fraction of a second: YYYY-MM-DDThh: mm:ss.sTZD (2023-05-22T17:00:25.45+01:00)
The letters used in the above format are:
- YYYY : Four-digit year
- MM : Two-digit month (01 = April, and so on)
- DD : Two-digit day of month (01 through 31)
- hh : Two digits of hour (00 through 23, a.m./p.m. NOT allowed)
- mm : Two digits of minute (00 through 59)
- ss : Two digits of second (00 through 59)
- s : One or more digits representing a decimal fraction of a second
- TZD : Time zone designator (Z or +hh:mm or -hh:mm)
Supporting Duration Formats
Travlinq API will support 1D12H35M
duration format.
- If duration is >= 24h then format is
1D12H35M
. - If duration is < 24h then format is
12H35M
.
D - Number of Dates. If duration is >= 24h then only day component will be appeared.
H - Number of Hours.
M - Number of Minutes.