clockwork 0.3.0__tar.gz → 0.3.2__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.0 → clockwork-0.3.2}/PKG-INFO +1 -1
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/__init__.py +1 -1
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/timestamp.py +47 -28
- {clockwork-0.3.0 → clockwork-0.3.2}/pyproject.toml +1 -1
- {clockwork-0.3.0 → clockwork-0.3.2}/LICENSE +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/README.md +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/constants.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/decorators.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/month_end.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/quarter_end.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/__init__.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/_scheduler.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/_task.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/file_monitor.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/logger.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/taskmaster.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/clockwork/taskmaster/utils.py +0 -0
- {clockwork-0.3.0 → clockwork-0.3.2}/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
|
|
@@ -482,6 +470,14 @@ class Timestamp(object):
|
|
|
482
470
|
return getattr(self.dt, name)
|
|
483
471
|
|
|
484
472
|
|
|
473
|
+
def __copy__(self):
|
|
474
|
+
return self.copy()
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def __deepcopy__(self, memo):
|
|
478
|
+
return self.copy()
|
|
479
|
+
|
|
480
|
+
|
|
485
481
|
def __repr__(self):
|
|
486
482
|
return str(self)
|
|
487
483
|
|
|
@@ -497,7 +493,7 @@ class Timestamp(object):
|
|
|
497
493
|
|
|
498
494
|
|
|
499
495
|
def __float__(self):
|
|
500
|
-
return self.
|
|
496
|
+
return self.to_timestamp()
|
|
501
497
|
|
|
502
498
|
|
|
503
499
|
def __int__(self):
|
|
@@ -563,22 +559,42 @@ class Timestamp(object):
|
|
|
563
559
|
|
|
564
560
|
def copy(self):
|
|
565
561
|
''' returns a deep copy of self '''
|
|
566
|
-
dt =
|
|
562
|
+
dt = self.to_datetime()
|
|
567
563
|
return self.__class__(dt)
|
|
568
564
|
|
|
569
565
|
|
|
566
|
+
def to_datetime(self):
|
|
567
|
+
''' returns a copy of the underlying datetime.datetime object '''
|
|
568
|
+
return deep_copy(self.dt)
|
|
569
|
+
|
|
570
|
+
|
|
570
571
|
def to_pandas(self):
|
|
571
572
|
''' return as a pd.Timestamp object '''
|
|
572
573
|
return pd.to_datetime(self.dt)
|
|
573
574
|
|
|
574
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
|
+
|
|
575
591
|
def to_string(self, fmt):
|
|
576
592
|
''' strftime alias '''
|
|
577
593
|
return self.strftime(fmt)
|
|
578
594
|
|
|
579
595
|
|
|
580
596
|
def str(self, *args, **kwargs):
|
|
581
|
-
'''
|
|
597
|
+
''' to_string() alias '''
|
|
582
598
|
return self.to_string(*args, **kwargs)
|
|
583
599
|
|
|
584
600
|
|
|
@@ -629,7 +645,7 @@ class Timestamp(object):
|
|
|
629
645
|
|
|
630
646
|
def _shift(self, **kwargs):
|
|
631
647
|
delta = self._build_delta(kwargs)
|
|
632
|
-
return self.
|
|
648
|
+
return self._make_base(self.dt + delta)
|
|
633
649
|
|
|
634
650
|
|
|
635
651
|
def shift(self, **kwargs):
|
|
@@ -702,7 +718,7 @@ class Timestamp(object):
|
|
|
702
718
|
#╰-------------------------------------------------------------------------╯
|
|
703
719
|
|
|
704
720
|
@staticmethod
|
|
705
|
-
def
|
|
721
|
+
def _make_base(*args, **kwargs):
|
|
706
722
|
return Timestamp(*args, **kwargs)
|
|
707
723
|
|
|
708
724
|
|
|
@@ -906,10 +922,13 @@ class Timestamp(object):
|
|
|
906
922
|
if isinstance(arg, datetime.date):
|
|
907
923
|
return cls._normalize(arg)
|
|
908
924
|
|
|
925
|
+
# timestamp expressed in seconds
|
|
909
926
|
if isinstance(arg, (float, int)):
|
|
910
|
-
#
|
|
911
|
-
|
|
912
|
-
|
|
927
|
+
# local time zone by default
|
|
928
|
+
return datetime.datetime.fromtimestamp(arg)
|
|
929
|
+
|
|
930
|
+
# UTC by default
|
|
931
|
+
# return pd.to_datetime(arg, unit='s').to_pydatetime()
|
|
913
932
|
|
|
914
933
|
raise TypeError(
|
|
915
934
|
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
|