XP is just a number | |
PerlMonks |
[Solved] Reading a timestamp and getting the written valueby davies (Prior) |
on Sep 03, 2022 at 15:32 UTC ( [id://11146660]=perlquestion: print w/replies, xml ) | Need Help?? |
davies has asked for the wisdom of the Perl Monks concerning the following question: X: I want to write timestamps to a text file in a reasonably human-friendly format and then read them back, getting the same epoch second for comparison with localtime. Y: my first attempt with Time::Piece:
This returns:
This is out by the timezone offset. The docs tell me to look at https://www.unix.com/man-page/FreeBSD/3/strftime/, which says that %z will be treated as a numerical offset. For me, this gives the same as upper case Z, although I can't rule out the influence of Windows on this. DateTime says it won't parse dates and gives no indication I could see of how to handle localtime. I'd be happy with UTC, but Time::Piece does not seem to support it, which is why I think I may have an XY problem. I can't believe that no-one has invented this wheel, but my searches have been fruitless and all the wheels I have tried seem square. I know that clocks moving back at the end of next month will bite me. All help gratefully received. Regards, John Davies
Back to
Seekers of Perl Wisdom
|
|