perldoc > Date::Manip::TZ

📛 NAME

Date::Manip::TZ - an interface to the time zone data

🚀 Quick Reference

Use CaseCommandDescription
Convert date between timezones$tz->convert($date, $from, $to)Convert a date from one time zone to another
Convert date to GMT$tz->convert_to_gmt($date, $from)Convert a date to GMT
Convert from GMT$tz->convert_from_gmt($date, $to)Convert a date from GMT to another time zone
Convert to local time$tz->convert_to_local($date, $from)Convert a date to the local time zone
Convert from local time$tz->convert_from_local($date, $to)Convert a date from the local time zone
Get current system time zone$tz->curr_zone()Return the system time zone
List all periods for a zone in a year$tz->periods($zone, $year)Return all time zone periods starting in a given year
Get period for a specific date$tz->date_period($date, $zone, $wall_clock)Return period information for a given date
Define abbreviation preferences$tz->define_abbrev($abbrev, @zone)Set order of zones to check for an abbreviation
Define alias$tz->define_alias($alias, $zone)Define a new alias or override an existing one
Define offset preferences$tz->define_offset($offset, $dstflag, @zone)Set order of zones to check for an offset
Find matching zones$tz->zone(@args)Return a list of zones matching criteria
Change current zone detection methods$tz->curr_zone_methods(@methods)Override the list of methods used to detect the local time zone

📖 SYNOPSIS

use Date::Manip::TZ;
$tz = new Date::Manip::TZ;

Data for most (and hopefully all) time zones used around the world have been gathered and is publicly available in the zoneinfo (or Olson) database.

This module uses the data from the zoneinfo database to perform various time zone operations.

📝 DESCRIPTION

Every time zone has some of the following characteristics:

Date::Manip includes all of the data for all of the time zones from the zoneinfo database. This data is available from:

ftp://ftp.iana.org/tz/

Additional data from other standards are also used.

The zoneinfo database is not necessary in order to use Date::Manip. Instead, all of that data has been extracted and stored in a series of other modules which are used to handle each time zone. In that way, Date::Manip has no dependency on any other source of data.

The Date::Manip::Zones document contains detailed information on the data available.

⚙️ METHODS

In all methods, the following variables are used:

The following methods are available:

🕐 TIME ZONE INFORMATION IN DATE::MANIP

Date::Manip makes use of three potentially different time zones when working with a date:

The local time zone is determined using the methods described in the next section. The working time zone can be changed via config variables (see Date::Manip::Config).

🔍 DETERMINING THE SYSTEM TIME ZONE

There are many ways to determine the time zone. A list of methods to use is provided by default, and may be overridden by the curr_zone_methods function. The following methods are available:

MethodArgument(s)Procedure
mainVARCheck the main variable named VAR (e.g. main TZ checks $::TZ).
envTYPE VARCheck the named environment variable. TYPE can be zone or offset (seconds from UTC).
fileFILELook in the given file for lines like ZONE, tz = ZONE, zone = ZONE, timezone = ZONE (case insensitive).
commandCOMMANDRun a command that produces a time zone as output.
cmdfieldCOMMAND NRun a command that produces whitespace-separated fields; the Nth field contains the time zone (fields numbered from 0, or from the end starting at -1).
gmtoff(none)Use the current offset from GMT to make a best guess.
tzdataFILE DIRUse a system config file that points to local tzdata files. E.g. tzdata /etc/localtime /usr/share/zoneinfo.
registry(none)Look up the value in the Windows registry (only available on Windows).

Note: The main and env methods should only be used to specify the actual system time zone. Use SetDate and ForceDate config variables to specify an alternate working time zone.

Default methods for Unix systems:

main     TZ
env      zone TZ
file     /etc/TIMEZONE
file     /etc/timezone
file     /etc/sysconfig/clock
file     /etc/default/init
command  "/bin/date +%Z"
command  "/usr/bin/date +%Z"
command  "/usr/local/bin/date +%Z"
cmdfield /bin/date             -2
cmdfield /usr/bin/date         -2
cmdfield /usr/local/bin/date   -2
command  "/bin/date +%z"
command  "/usr/bin/date +%z"
command  "/usr/local/bin/date +%z"
tzdata   /etc/localtime /usr/share/zoneinfo
gmtoff

Default methods for Windows systems:

main     TZ
env      zone TZ
registry
gmtoff

Default methods for VMS systems:

main     TZ
env      zone TZ
env      zone SYS$TIMEZONE_NAME
env      zone UCX$TZ
env      zone TCPIP$TZ
env      zone MULTINET_TIMEZONE
env      offset SYS$TIMEZONE_DIFFERENTIAL
gmtoff

Default methods for all other systems:

main     TZ
env      zone TZ
gmtoff

The value returned from any method may be a full time zone name (e.g. America/New_York), an alias, an abbreviation (e.g. EDT), or an offset (+hh, +hhmn, +hh:mm, +hh:mm:ss) from GMT.

💡 DESIGN ISSUES

The design decisions made in writing this module may cause some questions. The time zone modules are all generated using scripts that parse the standard tzdata files and store information in perl modules.

Why not use existing zoneinfo files?

Some may think I should have written an interface to the zoneinfo files distributed with most operating systems. I rejected the idea because:

Why not use the native tzdata files directly?

I parse the tzdata files and store the data in perl modules instead of creating an interface to the tzdata files directly. This was done for speed — Date::Manip is already slow, and complex parsing of tzdata files would slow it further. By storing data in modules, little or no parsing is done at runtime.

Why store information in so many files?

The data is stored in almost 500 Date::Manip::Offset::* modules and almost 450 Date::Manip::TZ::* modules. This is similar to the /usr/share/zoneinfo directory which contains over 1700 files. The modules are loaded only when the time zone or offset is actually used, so only a small number are loaded in most applications.

The disk space seems excessive?

Currently, the perl files use about 9 MB, while /usr/share/zoneinfo uses about 4 MB. The difference is due to the binary format of zoneinfo vs. plain text in perl modules. The modules include pod documentation, which is useful but adds space. Disk usage is not considered excessive.

⚠️ KNOWN PROBLEMS OR ISSUES

Unable to determine Time Zone

When Date::Manip is initialized, it must determine the local time zone. If it fails, an error "Unable to determine Time Zone" occurs and the script exits. This is less common with release 6.00. Refer to the "DETERMINING THE SYSTEM TIME ZONE" section for help.

Asia/Jerusalem time zone

The Asia/Jerusalem time zone uses a non-standard way of specifying DST based on the Hebrew calendar. This module supports all time zone changes currently specified in the zoneinfo database (up to year 2037) but does not attempt to handle changes beyond that date. Do not use Date::Manip for Jerusalem dates far in the future.

LMT and zzz abbreviations

Both LMT and zzz abbreviations are used in zoneinfo databases. LMT is used for most time zones before the Gregorian calendar was adopted, and zzz for a few others. Both are ignored in parsing dates (because there is no reasonable way to determine which zone they refer to) and will be treated as the local time zone.

🐛 KNOWN BUGS

None known.

❓ BUGS AND QUESTIONS

Please refer to the Date::Manip::Problems documentation for information on submitting bug reports or questions to the author.

📚 SEE ALSO

Date::Manip - main module documentation

📄 LICENSE

This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

👤 AUTHOR

Sullivan Beck (sbeck AT cpan.org)

Date::Manip::TZ
📛 NAME 🚀 Quick Reference 📖 SYNOPSIS 📝 DESCRIPTION ⚙️ METHODS 🕐 TIME ZONE INFORMATION IN DATE::MANIP 🔍 DETERMINING THE SYSTEM TIME ZONE 💡 DESIGN ISSUES
Why not use existing zoneinfo files? Why not use the native tzdata files directly? Why store information in so many files? The disk space seems excessive?
⚠️ KNOWN PROBLEMS OR ISSUES
Unable to determine Time Zone Asia/Jerusalem time zone LMT and zzz abbreviations
🐛 KNOWN BUGS ❓ BUGS AND QUESTIONS 📚 SEE ALSO 📄 LICENSE 👤 AUTHOR

Generated by phpman v4.9.29 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-20 18:39 @2600:1f28:365:80b0:8802:8bb4:3873:328e
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^