scipp.datetime#

scipp.datetime(value, *, unit=<scipp._scipp.core.DefaultUnit object>)#

Constructs a zero dimensional Variable with a dtype of datetime64.

Parameters
  • value (Union[str, int, datetime64]) –

    • str: Interpret the string according to the ISO 8601 date time format.

    • int: Number of time units (see argument unit) since scipp’s epoch

      (see scipp.epoch()).

    • np.datetime64: Construct equivalent datetime of scipp.

  • unit (Union[Unit, str, None], default: <scipp._scipp.core.DefaultUnit object at 0x7f749c6bf9b0>) – Unit of the resulting datetime. Can be deduced if value is a str or np.datetime64 but is required if it is an int.

Seealso

scipp.datetimes() scipp.epoch() ‘Dates and Times’ section in Data Types

Examples:

>>> sc.datetime('2021-01-10T14:16:15')
<scipp.Variable> ()  datetime64              [s]  [2021-01-10T14:16:15]
>>> sc.datetime('2021-01-10T14:16:15', unit='ns')
<scipp.Variable> ()  datetime64             [ns]  [2021-01-10T14:16:14.999999744]
>>> sc.datetime(1610288175, unit='s')
<scipp.Variable> ()  datetime64              [s]  [2021-01-10T14:16:15]
Return type

Variable