scipp.datetime

scipp.datetime

scipp.datetime(value, *, unit=None)

Constructs a zero dimensional Variable with a dtype of datetime64.

Seealso

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

Parameters
  • value (Union[str, int, numpy.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 (Optional[Union[scipp._scipp.core.Unit, str]]) – Unit of the resulting datetime. Can be deduced if value is a str or np.datetime64 but is required if it is an int.

Return type

scipp._scipp.core.Variable

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]