-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible issue regarding strptime() and TZs #52
Comments
Your code trace is right as far as I can tell. As far as it being a bug... perhaps. Equally so, I'd blame "poor documentation". But on another hand... it could be fixed, so maybe it is a bug after all?? 😁 Similar to #49 The docs show in many places: If you are dealing with local times, doing For your example, this would work:
|
Equally so, I'd blame the interface and the implementation. According to what I've discovered,
"...like that, the resulting time zone is UTC...". Because it successfully parses timestamps in arbitrary time zones.
Again, with local times, not with arbitrary time zones. At least that is my understanding. |
Tested platforms (3):
EXPECTED output:
ACTUAL output (on all three platforms, differing only by the path to Piece.pm, formatted for readability):
Test code:
The behavior also appears to occur if I change my $t = localtime; to my $t = gmtime; as well, where the timezone is then 'UTC'. If it were only occurring under Cygwin and Strawberry, my first guess would be MSWin-related, but since I am seeing it on a Linux system as well, I'm not sure where to look for the cause of the issue.
Before I consider it a bug, I want to make sure the issue is not on my side or in my understanding. This is part of the reason my sample code attempted to go from object to string and back to object-to test both the strftime() and strptime() methods.
My C is quite rusty (and I haven't dug around inside the perl source tree before), but it appears the process goes as follows when looking at the perl-5.30.3 source on MetaCPAN (PLEASE CORRECT ME IF YOU SPOT ANY ERRORS BELOW):
Based on the signature, it appears the second (on line 1025) is called. After loading the locale data structure via cpopulate_c_time_locale(aTHX locales ), this version of _strptime calls the version on line 345 as remainder = (char *)strptime(aTHX string, format, &mytm, &gotGMT). If this returns with anything other than a '\0', either an "Error parsing time" or "Garbage at end of string in strptime:" message is returned.
Questions:
Thank you for your time and attention. Stay safe!
See also:
Question regarding Time::Piece and timezones - PerlMonks
The text was updated successfully, but these errors were encountered: