spotify / luigi

Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
Apache License 2.0
17.91k stars 2.4k forks source link

`datetime.utcfromtimestamp()` converts `time.time()` to wrong datetime value in `luigi.tools.range.RangeBase` #3317

Open wangzhe258369 opened 1 month ago

wangzhe258369 commented 1 month ago

datetime.utcfromtimestamp() is used in the source code, which converts time.time() or self.now parameter value to the wrong datetime instance.

https://github.com/spotify/luigi/blob/829fc0c36ecb4d0ae4f0680dec6d538577b249a2/luigi/tools/range.py#L219

now = datetime.utcfromtimestamp(time.time() if self.now is None else self.now)

It should be:

now = datetime.fromtimestamp(time.time() if self.now is None else self.now)
VishalGawade1 commented 1 month ago

Hey @RRap0so!

I would like to contribute on this. I saw the issue with datetime.utcfromtimestamp() giving the wrong time. I think switching it to datetime.fromtimestamp() could fix it and return the correct local time.

Let me know!