Expand description

Date/Time expressions to use with Date/Time generators.

These expressions work relative to a base date + time, normally the current system clock. They provide a reliable way to work with relative dates in tests.

Given the base date-time of 2000-01-01T10:00Z, then the following will resolve to

ExpressionResulting date-time
‘’‘2000-01-01T10:00Z’
‘now’‘2000-01-01T10:00Z’
‘today’‘2000-01-01T10:00Z’
‘yesterday’‘1999-12-31T10:00Z’
‘tomorrow’‘2000-01-02T10:00Z’
‘+ 1 day’‘2000-01-02T10:00Z’
‘+ 1 week’‘2000-01-08T10:00Z’
‘- 2 weeks’‘1999-12-18T10:00Z’
‘+ 4 years’‘2004-01-01T10:00Z’
‘tomorrow+ 4 years’‘2004-01-02T10:00Z’
‘next week’‘2000-01-08T10:00Z’
‘last month’‘1999-12-01T10:00Z’
‘next fortnight’‘2000-01-15T10:00Z’
‘next monday’‘2000-01-03T10:00Z’
‘last wednesday’‘1999-12-29T10:00Z’
‘next mon’‘2000-01-03T10:00Z’
‘last december’‘1999-12-01T10:00Z’
‘next jan’‘2001-01-01T10:00Z’
‘next june + 2 weeks’‘2000-06-15T10:00Z’
‘last mon + 2 weeks’‘2000-01-10T10:00Z’
‘+ 1 day - 2 weeks’‘1999-12-19T10:00Z’
‘last december + 2 weeks + 4 days’‘1999-12-19T10:00Z’
‘@ now’‘2000-01-01T10:00Z’
‘@ midnight’‘2000-01-01T00:00Z’
‘@ noon’‘2000-01-01T12:00Z’
‘@ 2 o'clock’‘2000-01-01T14:00Z’
‘@ 12 o'clock am’‘2000-01-01T12:00Z’
‘@ 1 o'clock pm’‘2000-01-01T13:00Z’
‘@ + 1 hour’‘2000-01-01T11:00Z’
‘@ - 2 minutes’‘2000-01-01T09:58Z’
‘@ + 4 seconds’‘2000-01-01T10:00:04Z’
‘@ + 4 milliseconds’‘2000-01-01T10:00:00.004Z’
‘@ midnight+ 4 minutes’‘2000-01-01T00:04Z’
‘@ next hour’‘2000-01-01T11:00Z’
‘@ last minute’‘2000-01-01T09:59Z’
‘@ now + 2 hours - 4 minutes’‘2000-01-01T11:56Z’
‘@ + 2 hours - 4 minutes’‘2000-01-01T11:56Z’
‘today @ 1 o'clock’‘2000-01-01T13:00Z’
‘yesterday @ midnight’‘1999-12-31T00:00Z’
‘yesterday @ midnight - 1 hour’‘1999-12-30T23:00Z’
‘tomorrow @ now’‘2000-01-02T10:00Z’
‘+ 1 day @ noon’‘2000-01-02T12:00Z’
‘+ 1 week @ +1 hour’‘2000-01-08T11:00Z’
‘- 2 weeks @ now + 1 hour’‘1999-12-18T11:00Z’
‘+ 4 years @ midnight’‘2004-01-01T00:00Z’
‘tomorrow+ 4 years @ 3 o'clock + 40 milliseconds’‘2004-01-02T15:00:00.040Z’
‘next week @ next hour’‘2000-01-08T11:00Z’
‘last month @ last hour’‘1999-12-01T09:00Z’

Structs

  • Struct to represent an adjustment to a base date-time

Enums

Functions