1

An error occurs in Windows:

OSError: [Errno 22] Invalid argument

while everything works as it should in Linux

from datetime import datetime

a = datetime.fromtimestamp(0)
a.timestamp() # - an error occurs here

How can I fix this in Windows?

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
N.Maxim
  • 9
  • 3
  • 1
    expected output - 0.0 – N.Maxim Jun 09 '21 at 07:12
  • No, because it doesn't mention fromtimestamp. The problem in timestamp arises from the datetime object that was created with fromtimestamp(0) – N.Maxim Jun 09 '21 at 08:25
  • apologies for my initial comment, which I think was misleading. [this answer](https://stackoverflow.com/a/65564765/10197418) basically says "it's a Windows thing" and "doesn't happen with aware datetime" (which I can reproduce). But: it gives no clue as to *why* this happens on Windows. Anyhow, my takeaway would be: work with aware datetime whenever you can (preferably UTC) – FObersteiner Jun 09 '21 at 10:08

0 Answers0