:py:mod:`dissect.util.ts` ========================= .. py:module:: dissect.util.ts Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.util.ts.UTC Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.util.ts.now dissect.util.ts.unix_now dissect.util.ts.unix_now_ms dissect.util.ts.unix_now_us dissect.util.ts.unix_now_ns dissect.util.ts.to_unix dissect.util.ts.to_unix_ms dissect.util.ts.to_unix_us dissect.util.ts.to_unix_ns dissect.util.ts.from_unix dissect.util.ts.from_unix_ms dissect.util.ts.from_unix_us dissect.util.ts.from_unix_ns dissect.util.ts.xfstimestamp dissect.util.ts.wintimestamp dissect.util.ts.oatimestamp dissect.util.ts.webkittimestamp dissect.util.ts.cocoatimestamp dissect.util.ts.uuid1timestamp dissect.util.ts.dostimestamp Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.util.ts.ufstimestamp .. py:function:: now() -> datetime.datetime Return an aware datetime object of the current time in UTC. .. py:function:: unix_now() -> int Return a Unix timestamp of the current time. .. py:function:: unix_now_ms() -> int Return a Unix millisecond timestamp of the current time. .. py:function:: unix_now_us() -> int Return a Unix microsecond timestamp of the current time. .. py:function:: unix_now_ns() -> int Return a Unix nanosecond timestamp of the current time. .. py:function:: to_unix(dt: datetime.datetime) -> int Converts datetime objects into Unix timestamps. This is a convenience method. :param dt: The datetime object. :returns: Unix timestamp from the passed datetime object. .. py:function:: to_unix_ms(dt: datetime.datetime) -> int Converts datetime objects into Unix millisecond timestamps. This is a convenience method. :param dt: The datetime object. :returns: Unix millisecond timestamp from the passed datetime object. .. py:function:: to_unix_us(dt: datetime.datetime) -> int Converts datetime objects into Unix microsecond timestamps. This is a convenience method. :param dt: The datetime object. :returns: Unix microsecond timestamp from the passed datetime object. .. py:function:: to_unix_ns(dt: datetime.datetime) -> int Converts datetime objects into Unix nanosecond timestamps. This is a convenience method. :param dt: The datetime object. :returns: Unix nanosecond timestamp from the passed datetime object. .. py:function:: from_unix(ts: float) -> datetime.datetime Converts Unix timestamps to aware datetime objects in UTC. This is a convenience method. :param ts: The Unix timestamp. :returns: Datetime object from the passed timestamp. .. py:function:: from_unix_ms(ts: float) -> datetime.datetime Converts Unix timestamps in milliseconds to aware datetime objects in UTC. :param ts: The Unix timestamp in milliseconds. :returns: Datetime object from the passed timestamp. .. py:function:: from_unix_us(ts: float) -> datetime.datetime Converts Unix timestamps in microseconds to aware datetime objects in UTC. :param ts: The Unix timestamp in microseconds. :returns: Datetime object from the passed timestamp. .. py:function:: from_unix_ns(ts: float) -> datetime.datetime Converts Unix timestamps in nanoseconds to aware datetime objects in UTC. :param ts: The Unix timestamp in nanoseconds. :returns: Datetime object from the passed timestamp. .. py:function:: xfstimestamp(seconds: int, nano: int) -> datetime.datetime Converts XFS timestamps to aware datetime objects in UTC. :param seconds: The XFS timestamp seconds component :param nano: The XFS timestamp nano seconds component :returns: Datetime object from the passed timestamp. .. py:data:: ufstimestamp .. py:function:: wintimestamp(ts: int) -> datetime.datetime Converts Windows timestamps to aware datetime objects in UTC. :param ts: The Windows timestamp. :returns: Datetime object from the passed timestamp. .. py:function:: oatimestamp(ts: float) -> datetime.datetime Converts OLE Automation timestamps to aware datetime objects in UTC. :param ts: The OLE Automation timestamp. :returns: Datetime object from the passed timestamp. .. py:function:: webkittimestamp(ts: int) -> datetime.datetime Converts WebKit timestamps to aware datetime objects in UTC. :param ts: The WebKit timestamp. :returns: Datetime object from the passed timestamp. .. py:function:: cocoatimestamp(ts: int) -> datetime.datetime Converts Apple Cocoa Core Data timestamps to aware datetime objects in UTC. :param ts: The Apple Cocoa Core Data timestamp. :returns: Datetime object from the passed timestamp. .. py:function:: uuid1timestamp(ts: int) -> datetime.datetime Converts UUID version 1 timestamps to aware datetime objects in UTC. UUID v1 timestamps have an epoch of 1582-10-15 00:00:00. :param ts: The UUID version 1 timestamp :returns: Datetime object from the passed timestamp. .. py:function:: dostimestamp(ts: int, centiseconds: int = 0, swap: bool = False) -> datetime.datetime Converts MS-DOS timestamps to naive datetime objects. MS-DOS timestamps are recorded in local time, so we leave it up to the caller to add optional timezone information. According to http://www.vsft.com/hal/dostime.htm :param timestap: MS-DOS timestamp :param centisecond: Optional ExFAT centisecond offset. Yes centisecond... :param swap: Optional swap flag if date and time bytes are swapped. :returns: Datetime object from the passed timestamp. .. py:class:: UTC(tz_dict: Dict[str, int]) Bases: :py:obj:`datetime.tzinfo` tzinfo class for timezones that have a fixed-offset from UTC :param tz_dict: Dictionary of ``{"name": "timezone name", "offset": offset_from_UTC_in_minutes}`` .. py:method:: utcoffset(dt) datetime -> timedelta, positive for east of UTC, negative for west of UTC .. py:method:: tzname(dt) datetime -> string name of time zone. .. py:method:: dst(dt) datetime -> DST offset as timedelta, positive for east of UTC. Return 0 if DST not in effect. utcoffset() must include the DST offset.