date time arithmatic
Tim Roberts
timr at probo.com
Mon Jan 6 23:47:27 EST 2003
"Lexy Zhitenev" <zhitenev at cs.vsu.ru> wrote:
>
>If the dates you operate on are in the Unix Epoch (1970 - 2038), you can use
>"time.mktime" function.
>
>>>> import time
>>>> def now(d, m, y):
>... return int(time.mktime(d, m, y, 0, 0, 0, 0, 0, 0) / 86400) #
>86400 - number of seconds passed since 1970/1/1.
>
>So if you want to count the number of days between to dates use "now(2003,
>1, 5)-now(1982, 5, 23)"
However, to reduce confusion, you might want to rename those parameters to
"y, m, d" instead of "d, m, y" in both cases...
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list