i found something interesting during the timedate difference calculation

import datetime
import time

def main():
  mydatetime = datetime.datetime.now()
  time.sleep(1)
  mydatetime2 = datetime.datetime.now()
  diff = mydatetime - mydatetime2

  print(diff)

if __name__ == '__main__':
  main()

if you run this code the result you get will be
-1 day, 23:59:59

at least that is what i'm getting.

i was expecting to get -1 second. diff object is of type timedelta. this
kind of objects represent duration, at least that is what i understood from
the documentation (
http://docs.python.org/release/3.1.3/library/datetime.html#timedelta-objects).
so, is this a bug in the timedelta implementation or is it me not
understanding documentation properly?

any help is appreciated.

ps. i'm using python 3.1 on a windows xp machine.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to