(Jul-03-2023, 10:09 AM)snippsat Wrote: Then why are you adding a timezone,just add 24 hour to timestamp if that 's what you need.
From the OP, the goal is to find files that have a modification time that falls in some window (yesterday's timestamps). If you set the start time to now() and add 24 hours to get the end, you are looking in the future and no files will match the query.
If yesterday is yesterday in Kuala Lumpur, there could be files that were modified "today", so you need a start and end timestamp. In that case I would set the start time to "yesterday" and the end time to "today" using the Kuala Lumpur timezone (Asia/Kuala_Lumpur). I mentioned this in an earlier post. My thought was to create a DateTime object using today's date, time=0, and timezone=Kuala Lumpur, but I think snippsat is correct about using pendulum. Using pendulum this is all you need to get start and stop timestamps to find files that were modified yesterday in Kuala Lumpur.
tz = 'Asia/Kuala_Lumpur'
start_time = pendulum.yesterday(tz=tz).timestamp()
end_time = pendulum.today(tz=tz).timestamp()
So, what do you want tester? You've been pretty vague in all your descriptions. Does "yesterdays timestamps" start with yesterday() (yesterdays date, time = 00:00.00) and end with today() (todays date, time = 00:00.00). If so, for what time zone?
And there is still the question of daylight savings time. If you are using a local time, there will be gaps/overlaps in consecutive time windows when daylight savings time starts/ends. Does this matter?