Get time zone abbreviation with POSIX (Perl)

I would like to know if it is possible to get the time zone reduction (example: EST, CST, PST) just using POSIX? I can get the full name of the time zone (example: Pacific Standard Time) using POSIX with the following code:

use POSIX; print strftime("%Z", localtime()), "\n"; 

I know that there are modules available for date / time manipulation, but since I only need to get an abbreviation from the time zone, I would like to avoid using a large module just for that.

+4
source share
1 answer

Timezone databases are not part of the POSIX standard (or any other Unix). For proper timezone processing, you need a timezone database, such as the Olson database .

In Perl, you can use the DateTime module, which together with DateTime :: TimeZone will give you access to this database. Again, using such databases is only a way to properly handle time zones.

+3
source

Source: https://habr.com/ru/post/1393224/


All Articles