user3369743
user3369743

Reputation: 35

RFC3339 - Date when no time is specified

If a date is specified in the format start=2021-04-05&end=2021-05-05 does that mean that 2021-05-05 is excluded from the results? and it's returning up to 11:59:59 on the 4th?

In an API I'm using, it seems to be behaving the same as start=2021-04-05T00:00:00Z&end=2021-05-05T00:00:00Z when no time is specified.

Upvotes: 0

Views: 1780

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241808

A few things:

  • I think you are asking about the full-date format from RFC 3339, which is the same as the ISO 8601 extended date format: YYYY-MM-DD

  • Neither specification says anything about inclusivity or exclusivity of date-only ranges.

    • ISO 8601 does talk a bit about ranges (they call them intervals), but they are defined as a pair of instants, not whole dates.
  • The typical best practice (in my experience) would be to use a fully inclusive range for date-only values, or a half-open range for date-time values. For example:

    [2021-04-05, 2021-05-05]
    [2021-04-05T00:00:00, 2021-04-06T00:00:00)
    

    However, this is not a hard rule. The actual details would be highly specific to the particular API you are using and how the authors of that API designed it to function.

  • A whole date like 2021-04-05 is not necessarily the same thing as 2021-04-05T00:00:00. In many cases, the reason to use a whole date is to not associate a time or a time zone at all. But again, this is highly implementation specific.

  • Nothing you've shown would imply that UTC (Z) is being used. If that's how the API is behaving, that's another implementation detail of that API.

Upvotes: 2

Related Questions