@@ -157,6 +157,7 @@ def __eq__(self, o: "dTS") -> bool:
157157 def __radd__ (self , other ):
158158 return self .__add__ (other )
159159
160+
160161@total_ordering
161162class BaseTS (ABC , metaclass = ABCMeta ):
162163 @classmethod
@@ -347,21 +348,20 @@ def isoformat(self, sep='T', timespec='auto') -> str:
347348
348349 iso = isoformat
349350
350- def iso_date (self ) -> str :
351+ def iso_date (self , sep = "-" , use_zulu : bool = False ) -> str :
351352 """
352353 Returns Extended ISO date format.
353354 Example: 2021-01-01
354355 """
355- s = self . as_dt (). strftime ( "%Y-%m-%d" )
356- return s
356+ zulu_designator = "Z" if use_zulu else ""
357+ return self . as_dt (). strftime ( f"%Y { sep } %m { sep } %d { zulu_designator } " )
357358
358- def iso_date_basic (self ) -> str :
359+ def iso_date_basic (self , use_zulu : bool = False ) -> str :
359360 """
360361 Returns Basic ISO date format.
361362 Example: 20210101
362363 """
363- s = self .as_dt ().strftime ("%Y%m%d" )
364- return s
364+ return self .iso_date (sep = "" , use_zulu = use_zulu )
365365
366366 def iso_tz (self , tz : Union [str , tzinfo ]) -> str :
367367 """
@@ -372,8 +372,7 @@ def iso_tz(self, tz: Union[str, tzinfo]) -> str:
372372 tz = pytz .timezone (tz )
373373 dt = self .as_dt (tz = tz )
374374 s = dt .isoformat ()
375- s = s .replace ("+00:00" , "Z" )
376- return s
375+ return s .replace ("+00:00" , "Z" )
377376
378377 def iso_basic (self , sep = "-" , use_zulu : bool = False ) -> str :
379378 """
@@ -382,8 +381,7 @@ def iso_basic(self, sep="-", use_zulu: bool = False) -> str:
382381 """
383382 dt = self .as_dt ()
384383 zulu_designator = "Z" if use_zulu else ""
385- s = dt .strftime (f"%Y%m%d{ sep } %H%M%S{ zulu_designator } " )
386- return s
384+ return dt .strftime (f"%Y%m%d{ sep } %H%M%S{ zulu_designator } " )
387385
388386 def as_sec (self ) -> "iTS" :
389387 """
@@ -693,7 +691,6 @@ def __lt__(self, o: object) -> bool:
693691 return False
694692
695693
696-
697694class TSMsec (TS ):
698695 def __new__ (cls , ts : Union [int , float , str ], prec : Literal ["s" , "ms" ] = "ms" ):
699696 if isinstance (ts , TS ):
@@ -808,7 +805,7 @@ def __eq__(self, o: object) -> bool:
808805 if isinstance (o , BaseTS ):
809806 return int .__eq__ (self .as_nsec (), o .as_nsec ())
810807 if isinstance (o , Real ):
811- return int .__eq__ (int (self ),o )
808+ return int .__eq__ (int (self ), o )
812809 return False
813810
814811 def __ne__ (self , o : object ) -> bool :
@@ -819,6 +816,7 @@ def __hash__(self) -> int:
819816 nsec = self .as_nsec ()
820817 return int .__hash__ (nsec )
821818
819+
822820class iTS (iBaseTS ):
823821 """
824822 Represents Unix timestamp in seconds since Epoch, by default in UTC.
0 commit comments