Timestamp¶
-
class pymkv.Timestamp(timestamp: str | int | Timestamp | None =
None
, hh: int | None =None
, mm: int | None =None
, ss: int | None =None
, nn: int | None =None
, form: str ='MM:SS'
)¶ - extract(timestamp: str | int) None ¶
Extracts time info from a timestamp.
- timestamp (str, int):
A str of a timestamp acceptable to mkvmerge or an int representing seconds. The timing info will be extracted from this parameter.
- property form : str¶
Get the format string for the timestamp.
- property hh : int¶
Get the hours component of the timestamp.
- property mm : int¶
Get the minutes component of the timestamp.
- property nn : int¶
Get the nanoseconds component of the timestamp.
- splitting_timestamp(timestamp: str) None ¶
This method splits the given timestamp string into hours, minutes, seconds, and nanoseconds. The timestamp string should be in the format “HH:MM:SS.NNNNNNNNN”, where HH represents hours, MM represents minutes, SS represents seconds, and NNNNNNNNN represents nanoseconds.
Example
>>> obj = Timestamp("12:34:56.789012345") >>> print(obj) 12:34:56.789012345 >>> assert obj.hh == 12 >>> assert obj.mm == 34 >>> assert obj.ss == 56 >>> assert obj.nn == 789012345
# Assuming self._hh, self._mm, self._ss, and self._nn are all None initially The hours (self.hh) will be set to 12. The minutes (self.mm) will be set to 34. The seconds (self.ss) will be set to 56. The nanoseconds (self.nn) will be set to 789012345.
- property ss : int¶
Get the seconds component of the timestamp.
- property ts : str¶
Generates and returns the timestamp string specified by the object.
- Returns:¶
A formatted timestamp string based on the object’s properties and format.
- Return type:¶
str
The timestamp format is determined by the ‘form’ attribute and includes hours (HH), minutes (MM), seconds (SS), and nanoseconds (NN) as applicable. The method constructs the timestamp string according to the specified format, including or omitting parts based on the format and the presence of non-zero values.