nstime2timestr¶
- pymseed.nstime2timestr(nstime, timeformat=TimeFormat.ISOMONTHDAY_Z, subsecond=SubSecond.NANO_MICRO_NONE)[source]¶
Convert a nanosecond timestamp to a date-time string
The returned string is a subset of the RFC 3339 (ISO 8601 profile) and always in UTC (Z suffix optional).
timeformatselects the overall layout viaTimeFormat(ISO month-day withTor space, optional trailingZ, SEED ordinal day-of-year, Unix epoch seconds, or nanosecond epoch). The default isISOMONTHDAY_Z(YYYY-MM-DDThh:mm:ss[.fraction]Z).subsecondselects how fractional seconds are shown viaSubSecond: fixed none / micro / nano resolution, or conditional forms that omit trailing zero fractions. The default,NANO_MICRO_NONE, uses nanoseconds when needed, otherwise microseconds when needed, otherwise no fractional part.Examples
>>> from pymseed import nstime2timestr, timestr2nstime, TimeFormat, SubSecond >>> t = timestr2nstime("2024-03-15T10:30:00.123456789Z") >>> nstime2timestr(t) '2024-03-15T10:30:00.123456789Z' >>> nstime2timestr(t, subsecond=SubSecond.MICRO) '2024-03-15T10:30:00.123456Z' >>> nstime2timestr(t, timeformat=TimeFormat.ISOMONTHDAY_SPACE_Z, subsecond=SubSecond.NONE) '2024-03-15 10:30:00Z'
- Parameters:
nstime (int)
timeformat (TimeFormat)
subsecond (SubSecond)
- Return type: