scipp.datetime#
- scipp.datetime(value, *, unit=<automatically deduced unit>)#
Constructs a zero dimensional
Variable
with a dtype of datetime64.- Parameters:
value (
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 (seescipp.epoch()
).np.datetime64: Construct equivalent datetime of Scipp.
unit (
Unit
ofthe resulting datetime.
) – Can be deduced ifvalue
is a str or np.datetime64 but is required if it is an int.
- Returns:
Variable
– A scalar variable containing a datetime.
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:15.000000000 >>> sc.datetime(1610288175, unit='s') <scipp.Variable> () datetime64 [s] 2021-01-10T14:16:15
Get the current time:
>>> now = sc.datetime('now', unit='s')