Title: Error parsing time-zone with Tim75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Piece
Tags: perl
Question: Executing a simple Perl script
use Tim75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Piece;
my $t = Tim75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Piece-&gt;strptime('08:00 PM AST', "%I:%M %p %Z");
I got the following error: Error parsing time at /usr/local/lib/perl5/Time/Piece.pm line 469.
Is this a bug in the library or there is something wrong with the above code? When I remove AST time-zone from the input string, it works, but when time-zone is left, it fails.
I don't know what exact time-zone will be in input string, so I cannot adjust that part on my end. AST (see Wikipedia) is a proper abbreviation for Atlantic Time Zone, so it should work. But it does not!

Here is the accepted answer: use Dat75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Parse;
my $t = str2time('08:00 PM AST');
Comment for this answer: That's fine if it does what you need. But you will get Unix time values instead of `Tim75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Piece` objects, and it will get a substantial number of the world's time zones wrong.

Here is another answer: The time zone field is ambiguous and cannot be parsed. For instance, CST is the abbreviation for China Standard Time, Central Standard Time, and Cuba Standard Time.
The module documentation says that the strptime method is from FreeBSD, where the %Z format accepts either the local time zone or GMT and nothing else. This may be true of strptime, but I can confirm only that, where I am located, GMT is acceptable while UTC and AST are not.
The solution I would recommend is to preprocess your time strings, replacing the time zone abbreviation with an unambiguous time zone offset. For instance AST (assuming you meant Atlantic Standard Time and not Arabia Standard Time) would be replaced with -0400, since it is four hours behind UTC. Then you can parse it with a %z format specifier and get the correct result.
Comment for this answer: I've added to my answer.
Comment for this answer: `Tim75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Piece->strptime("...", "...%Z")` accepts only [`GMT`](https://github.com/Dual-Life/Time-Piece/blob/1.3401/Piece.xs#L826) (the variable name is misleading). `localtime->strptime("...", "...%Z")` ignores the time zone. More on it [here](https://gist.github.com/x-yuri/4aa50308bab6bb41c5c8dd8ebdc7defb), and probably [here](https://github.com/Dual-Life/Time-Piece/issues/52#issuecomment-1246310525).

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:01/14/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<perl>', 'Title': 'Error parsing time-zone with Time::Piece', 'ViewCount': 1406, 'id': 21104478, 'user_AboutMe': '', 'user_AccountId': 1255572.0, 'user_DisplayName': 'Ωmega', 'user_Reputation': 40917.0, 'user_Views': 4310.0, 'user_id': 1215106.0}}