0
dateutil.parser.parse("0" , tzinfos={'GMT': tzutc()}) 

on windows give error

ValueError: Invalid timestamp "0": day is out of range for month.

python 2.7.13

Risadinha
  • 16,058
  • 2
  • 88
  • 91
  • 2
    months no doubt start from 1. Also can you clarify your import statements? I don't see a `dateutils.parser`, but there is a `dateutil.parser`. – Paul Rooney May 17 '17 at 03:45
  • sure it is dateutil.parser and import statements are import dateutil import dateutil.parser. But there is code in botocore. test case is https://github.com/boto/botocore/blob/develop/tests/unit/test_utils.py function name is def test_handles_string_epoch(self):. It calls the same function with value 0. I am not able to understand, eighter they didn't test on windows, or i am missing something – mayank sharma May 17 '17 at 04:25
  • I see the same thing on linux, it's not windows specific. I don't see how it can glean any kind of date from simply one number. For me, if I change it to "1" it uses that value as the day and produces a date `datetime.datetime(2017, 5, 1, 0, 0)`. – Paul Rooney May 17 '17 at 04:29
  • having read that test. I believe its trying to convert the 0 to a seconds since epoch value. So 0 becomes 00:00 1st Jan 1970. The month or day should not enter into the calculation. I think dateutil attempts to use some kind of logic to guess what the string means and it gets it wrong. It's also not clear what `parse_to_aware_datetime` does. – Paul Rooney May 17 '17 at 04:41
  • yes thanks a lot, found the same. It thinks dateuqils considers 0 as time and not as day and then tries to convert it to 00:00. Date utils uses some logic to convert 0 to 00:00 but its not successful 100% of the time and thus errors out. But some how it runs on Mac with python 2.7.13 and considers 0 as 00:00 when the test case parse_to_aware_datetime is run.thanks though – mayank sharma May 17 '17 at 18:01

0 Answers0