File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ def parse_timestamp(s):
165165 return parse (s )
166166
167167
168- def parse_duration_or_timestamp (s , duration_type = relativedelta ):
168+ def parse_duration_or_timestamp (s , delta_type = relativedelta ):
169169 """
170170 Convert the string *s* to a :class:`~datetime.datetime` or a
171171 :class:`~dateutil.relativedelta.relativedelta` (or
@@ -174,6 +174,6 @@ def parse_duration_or_timestamp(s, duration_type=relativedelta):
174174 attempted. A :exc:`ValueError` is raised if both conversions fail.
175175 """
176176 try :
177- return parse_duration (s , duration_type = duration_type )
177+ return parse_duration (s , delta_type = delta_type )
178178 except ValueError :
179179 return parse_timestamp (s )
Original file line number Diff line number Diff line change 1818
1919from ..analyzer import Analyzer
2020from ..errors import ValidationWarning
21- from ..conversions import parse_duration_or_timestamp , parse_timestamp
2221from ..types import sources_list , SourcesList
2322from ..source import Source
2423from ..xml import xml , get_transform
24+ from ..conversions import (
25+ parse_duration ,
26+ parse_duration_or_timestamp ,
27+ parse_timestamp ,
28+ )
2529
2630try :
2731 import argcomplete
@@ -360,7 +364,7 @@ def max_timestamp(s, now=_start):
360364
361365def timestamps (s ):
362366 try :
363- unit , epoch = {
367+ return {
364368 # The Excel epoch is defined as 1900-01-01, but that is date "1"
365369 # in Excel, rather than "0". Furthermore, for compat. with good
366370 # ol' 1-2-3, 1900 was treated (incorrectly) as a leap-year leading
Original file line number Diff line number Diff line change @@ -35,10 +35,15 @@ def test_max_timestamp():
3535 assert cli .max_timestamp ('10 years' ) == cli ._start + relativedelta (years = 10 )
3636
3737
38- def test_epoch ():
39- assert cli .epoch ('unix' ) == dt .datetime (1970 , 1 , 1 )
40- assert cli .epoch ('excel' ) == dt .datetime (1899 , 12 , 30 )
41- assert cli .epoch ('2015-03-31 00:00:00' ) == dt .datetime (2015 , 3 , 31 )
38+ def test_timestamps ():
39+ assert cli .timestamps ('unix' ) == (
40+ dt .timedelta (seconds = 1 ), dt .datetime (1970 , 1 , 1 ))
41+ assert cli .timestamps ('excel' ) == (
42+ dt .timedelta (days = 1 ), dt .datetime (1899 , 12 , 30 ))
43+ assert cli .timestamps ('2015-03-31 00:00:00' ) == (
44+ dt .timedelta (seconds = 1 ), dt .datetime (2015 , 3 , 31 ))
45+ assert cli .timestamps ('milliseconds since 1900-01-01' ) == (
46+ dt .timedelta (milliseconds = 1 ), dt .datetime (1900 , 1 , 1 ))
4247
4348
4449def test_num ():
Original file line number Diff line number Diff line change @@ -664,14 +664,14 @@ def test_num_repr():
664664 dt .datetime .utcfromtimestamp (1 ),
665665 dt .datetime .utcfromtimestamp (86400 ),
666666 ))), pattern = (Int , 1 , 0 ))
667- assert str (pattern ) == 'int seconds after 1970-01-01 of datetime range=1970-01-01 00:00:00..1970-01-02 00:00:00'
667+ assert str (pattern ) == 'int seconds since 1970-01-01 of datetime range=1970-01-01 00:00:00..1970-01-02 00:00:00'
668668 assert xml (pattern ).tag == 'intof'
669669 pattern = NumRepr (DateTime (Counter ((
670670 dt .datetime .utcfromtimestamp (0.0 ),
671671 dt .datetime .utcfromtimestamp (1.0 ),
672672 dt .datetime .utcfromtimestamp (86400.0 ),
673673 ))), pattern = (Float , 1 , 0 ))
674- assert str (pattern ) == 'float seconds after 1970-01-01 of datetime range=1970-01-01 00:00:00..1970-01-02 00:00:00'
674+ assert str (pattern ) == 'float seconds since 1970-01-01 of datetime range=1970-01-01 00:00:00..1970-01-02 00:00:00'
675675 assert xml (pattern ).tag == 'floatof'
676676 assert pattern == pattern + pattern
677677 assert pattern + pattern == pattern
You can’t perform that action at this time.
0 commit comments