clockwork 0.3.1__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {clockwork-0.3.1 → clockwork-0.3.3}/PKG-INFO +1 -1
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/__init__.py +1 -1
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/timestamp.py +41 -29
- {clockwork-0.3.1 → clockwork-0.3.3}/pyproject.toml +1 -1
- {clockwork-0.3.1 → clockwork-0.3.3}/LICENSE +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/README.md +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/constants.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/decorators.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/month_end.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/quarter_end.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/__init__.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/_scheduler.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/_task.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/file_monitor.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/logger.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/taskmaster.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/taskmaster/utils.py +0 -0
- {clockwork-0.3.1 → clockwork-0.3.3}/clockwork/utils.py +0 -0
|
@@ -119,7 +119,7 @@ class Timestamp(object):
|
|
|
119
119
|
# Otherwise, 'other' is assumed to be a delta and the resulting
|
|
120
120
|
# Timestamp object is returned.
|
|
121
121
|
delta = self._build_delta(other)
|
|
122
|
-
return self.
|
|
122
|
+
return self._make_base(func(self, delta))
|
|
123
123
|
|
|
124
124
|
return wrapper
|
|
125
125
|
|
|
@@ -274,8 +274,8 @@ class Timestamp(object):
|
|
|
274
274
|
|
|
275
275
|
@property
|
|
276
276
|
def date(self):
|
|
277
|
-
'''
|
|
278
|
-
return self.
|
|
277
|
+
''' to_date() alias '''
|
|
278
|
+
return self.to_date()
|
|
279
279
|
|
|
280
280
|
|
|
281
281
|
@property
|
|
@@ -286,7 +286,7 @@ class Timestamp(object):
|
|
|
286
286
|
|
|
287
287
|
@property
|
|
288
288
|
def pandas(self):
|
|
289
|
-
'''
|
|
289
|
+
''' to_pandas() alias '''
|
|
290
290
|
return self.to_pandas()
|
|
291
291
|
|
|
292
292
|
|
|
@@ -296,28 +296,16 @@ class Timestamp(object):
|
|
|
296
296
|
return self.to_string('%Y-%m-%d')
|
|
297
297
|
|
|
298
298
|
|
|
299
|
-
@property
|
|
300
|
-
def sql_server(self):
|
|
301
|
-
''' ymd alias '''
|
|
302
|
-
return self.ymd
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
@property
|
|
306
|
-
def oracle(self):
|
|
307
|
-
''' string in DD-%b-YY (e.g. 30-Sep-19) format '''
|
|
308
|
-
return self.to_string('%d-%b-%y')
|
|
309
|
-
|
|
310
|
-
|
|
311
299
|
@property
|
|
312
300
|
def timestamp(self):
|
|
313
|
-
'''
|
|
314
|
-
return self.
|
|
301
|
+
''' to_timestamp() alias '''
|
|
302
|
+
return self.to_timestamp()
|
|
315
303
|
|
|
316
304
|
|
|
317
305
|
@property
|
|
318
306
|
def time(self):
|
|
319
|
-
'''
|
|
320
|
-
return self.
|
|
307
|
+
''' to_time() alias '''
|
|
308
|
+
return self.to_time()
|
|
321
309
|
|
|
322
310
|
|
|
323
311
|
@property
|
|
@@ -505,7 +493,7 @@ class Timestamp(object):
|
|
|
505
493
|
|
|
506
494
|
|
|
507
495
|
def __float__(self):
|
|
508
|
-
return self.
|
|
496
|
+
return self.to_timestamp()
|
|
509
497
|
|
|
510
498
|
|
|
511
499
|
def __int__(self):
|
|
@@ -571,22 +559,42 @@ class Timestamp(object):
|
|
|
571
559
|
|
|
572
560
|
def copy(self):
|
|
573
561
|
''' returns a deep copy of self '''
|
|
574
|
-
dt =
|
|
562
|
+
dt = self.to_datetime()
|
|
575
563
|
return self.__class__(dt)
|
|
576
564
|
|
|
577
565
|
|
|
566
|
+
def to_datetime(self):
|
|
567
|
+
''' returns a copy of the underlying datetime.datetime object '''
|
|
568
|
+
return deep_copy(self.dt)
|
|
569
|
+
|
|
570
|
+
|
|
578
571
|
def to_pandas(self):
|
|
579
572
|
''' return as a pd.Timestamp object '''
|
|
580
573
|
return pd.to_datetime(self.dt)
|
|
581
574
|
|
|
582
575
|
|
|
576
|
+
def to_timestamp(self):
|
|
577
|
+
''' returns timestamp expressed in seconds '''
|
|
578
|
+
return self.to_pandas().timestamp()
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def to_date(self):
|
|
582
|
+
''' return the date component as a 'datetime.date' object '''
|
|
583
|
+
return self.dt.date()
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
def to_time(self):
|
|
587
|
+
''' returns the time component as a 'datetime.time' object '''
|
|
588
|
+
return self.dt.time()
|
|
589
|
+
|
|
590
|
+
|
|
583
591
|
def to_string(self, fmt):
|
|
584
592
|
''' strftime alias '''
|
|
585
593
|
return self.strftime(fmt)
|
|
586
594
|
|
|
587
595
|
|
|
588
596
|
def str(self, *args, **kwargs):
|
|
589
|
-
'''
|
|
597
|
+
''' to_string() alias '''
|
|
590
598
|
return self.to_string(*args, **kwargs)
|
|
591
599
|
|
|
592
600
|
|
|
@@ -637,7 +645,7 @@ class Timestamp(object):
|
|
|
637
645
|
|
|
638
646
|
def _shift(self, **kwargs):
|
|
639
647
|
delta = self._build_delta(kwargs)
|
|
640
|
-
return self.
|
|
648
|
+
return self._make_base(self.dt + delta)
|
|
641
649
|
|
|
642
650
|
|
|
643
651
|
def shift(self, **kwargs):
|
|
@@ -710,7 +718,7 @@ class Timestamp(object):
|
|
|
710
718
|
#╰-------------------------------------------------------------------------╯
|
|
711
719
|
|
|
712
720
|
@staticmethod
|
|
713
|
-
def
|
|
721
|
+
def _make_base(*args, **kwargs):
|
|
714
722
|
return Timestamp(*args, **kwargs)
|
|
715
723
|
|
|
716
724
|
|
|
@@ -901,7 +909,8 @@ class Timestamp(object):
|
|
|
901
909
|
|
|
902
910
|
return pd.to_datetime(arg, **kwargs).to_pydatetime()
|
|
903
911
|
|
|
904
|
-
|
|
912
|
+
# Timestamp instance (or subclass)
|
|
913
|
+
if isinstance(arg, Timestamp):
|
|
905
914
|
return arg.dt
|
|
906
915
|
|
|
907
916
|
# pandas object
|
|
@@ -914,10 +923,13 @@ class Timestamp(object):
|
|
|
914
923
|
if isinstance(arg, datetime.date):
|
|
915
924
|
return cls._normalize(arg)
|
|
916
925
|
|
|
926
|
+
# timestamp expressed in seconds
|
|
917
927
|
if isinstance(arg, (float, int)):
|
|
918
|
-
#
|
|
919
|
-
|
|
920
|
-
|
|
928
|
+
# local time zone by default
|
|
929
|
+
return datetime.datetime.fromtimestamp(arg)
|
|
930
|
+
|
|
931
|
+
# UTC by default
|
|
932
|
+
# return pd.to_datetime(arg, unit='s').to_pydatetime()
|
|
921
933
|
|
|
922
934
|
raise TypeError(
|
|
923
935
|
f"'arg' of type <{type(arg).__name__}> "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|