ShriyansAgro

plone.restapi timeZone failing testcase #377

Aug 23rd, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. **Value has specified TimeZone info**
  2. (Pdb) value = '2017-08-15T19:00:00+05:30'
  3. (Pdb) DateTime(value).asdatetime()
  4. datetime.datetime(2017, 8, 15, 19, 0, tzinfo=<StaticTzInfo 'GMT+0530'>)
  5. (Pdb) DateTime(value).toZone(DateTime().localZone()).asdatetime()
  6. datetime.datetime(2017, 8, 15, 13, 30, tzinfo=<UTC>)
  7. (Pdb) DateTime(value).toZone(DateTime().localZone()).asdatetime().replace(tzinfo=None)
  8. datetime.datetime(2017, 8, 15, 13, 30)
  9. (Pdb) DateTime(value).toZone(DateTime().localZone()).asdatetime().replace(tzinfo=pytz.timezone(DateTime().localZone()))
  10. datetime.datetime(2017, 8, 15, 13, 30, tzinfo=<UTC>)
  11. ** Notice the ambiguity in change in value after desearialized**
  12.  
  13. **Value doesn't have any specified TimeZone info**
  14. (Pdb) value = '2017-08-15T19:00:00'
  15. (Pdb) DateTime(value)
  16. DateTime('2017/08/15 19:00:00 GMT+0')
  17. (Pdb) DateTime(value).toZone(DateTime().localZone()).asdatetime().replace(tzinfo=None)
  18. datetime.datetime(2017, 8, 15, 19, 0)
  19.  
  20. v = datetime.datetime(2015, 12, 20, 10, 39, 54, 361000, tzinfo=pytz.timezone('UTC'))
  21. vm = datetime.datetime(2015, 12, 20, 10, 39, 54, 361000)
  22.  
  23. if v == vm:
  24. ...: print 'solved'
  25. TypeError: can't compare offset-naive and offset-aware datetimes
Add Comment
Please, Sign In to add comment