Eno::Loaders ยป #datetime

datetime โ†’ Time
datetime_items โ†’ array
datetime_list โ†’ array

Accepts a subset of ISO 8601 date/time formats described in this W3C note: https://www.w3.org/TR/NOTE-datetime

Returns a ruby Time object (or raises an error for invalid values).

Some possible example values that match the format:

  • 1990
  • 1990-12
  • 1990-12-31
  • 1990-12-31T23:59Z
  • 1990-12-31T23:59:00+01:00
  • 1990-12-31T23:59:00.999+01:00

Note that spaces as separators are not allowed.

Development note: A more appealing, less technical datetime format or an additional loader to serve that requirement would be generally welcome, the current format is basically just an initial draft that should cover many usecases and is standardized through its ISO origin, feel free to get in touch and propose an extension/update if you'd be interested in such development.

enostart: 1992-12-01
end: 1994-03-04T13:14Z
invalid: 2018-03-14 13:10
rubydocument = Eno.parse(input)

document.datetime('start')  #=> 1992-12-01 00:00:00 +0000
document.datetime('end')  #=> 1994-03-04 13:14:00 +0000

  # raises an error: 'invalid' must contain a valid date or date and time, for instance '1997-07-16' or '1994-11-05T13:15Z' (see https://www.w3.org/TR/NOTE-datetime).