metasync
metasync

Reputation: 348

Is there a standard to represent relative date codes?

Is there a standard or at least generally accepted convention to represent relative dates?

For ex.,

-5d => 5 days ago
5d 4m 3s => 5 days, 4 minutes and 3 secs

where units are y, M, d, h, m, s

Note that I checked on the question but that talks about absolute date ranges but here I'm looking for relative date conventions.

Upvotes: 0

Views: 424

Answers (1)

Adam Millerchip
Adam Millerchip

Reputation: 23091

I think you are looking for ISO 8601 Time intervals, specifically Durations.

There are four ways to express a time interval:

  1. Start and end, such as "2007-03-01T13:00:00Z/2008-05-11T15:30:00Z"
  2. Start and duration, such as "2007-03-01T13:00:00Z/P1Y2M10DT2H30M"
  3. Duration and end, such as "P1Y2M10DT2H30M/2008-05-11T15:30:00Z"
  4. Duration only, such as "P1Y2M10DT2H30M", with additional context information

Upvotes: 1

Related Questions