Message133207
On 04/05/2011 18:22, Alexander Belopolsky wrote:
> """
> The datetime module intended to be an island of relative sanity.
> ....... """ - Tim Peters
Refusing to cooperate with the rest of the world is not sane by my books.
On 04/05/2011 21:06, Alexander Belopolsky wrote:
> Converting datetime values to float is easy. If your dt is a naive instance representing UTC time:
>
> timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)
>
> If your dt is an aware instance:
>
> timestamp = (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)) / timedelta(seconds=1)
Please add these lines to the datetime module's documentation. In some
central, well lit place. I believe that if nothing else, the whole
discussion should have proved to you that there are many people looking
for them.
OTOH a sinceepoch(epoch=datetime(1970,1,1)) method of the datetime class
should be equally easy. Would be especially useful if few of the more
frequently used EPOCHs are provided as constants. |
|
Date |
User |
Action |
Args |
2011-04-07 10:20:45 | vivanov | set | recipients:
+ vivanov, lemburg, tim.peters, ping, jribbens, guettli, amaury.forgeotdarc, mark.dickinson, davidfraser, belopolsky, pitrou, andersjm, catlee, vstinner, tomster, werneck, hodgestar, Neil Muller, erik.stephens, steve.roberts, r.david.murray, Jay.Taylor |
2011-04-07 10:20:44 | vivanov | link | issue2736 messages |
2011-04-07 10:20:43 | vivanov | create | |
|