DateTim...e::Local(3)
hey bestie π this is the DateTime::TimeZone::Local manual page β section 3, from the User Contributed Perl Documentation β and itβs all about figuring out your local systemβs time zone. Letβs get into it! π
π NAME π
DateTime::TimeZone::Local β Determine the local system's time zone
β¨ VERSION β¨
version 2.64
π¦ SYNOPSIS π¦
my $tz = DateTime::TimeZone->new( name => 'local' );
my $tz = DateTime::TimeZone::Local->TimeZone();
π DESCRIPTION π
This module provides an interface for determining the local system's time zone. Most of the functionality for doing this is in OS-specific subclasses. no cap, thatβs the whole vibe π
π USAGE π
This class provides the following methods:
π DateTime::TimeZone::Local->TimeZone() π
This attempts to load an appropriate subclass and asks it to find the local time zone. This method is called by when you pass local as the time zone name to DateTime:TimeZone->new().
If your OS is not explicitly handled, you can create a module with a name of the form DateTime::TimeZone::Local::$^O. If it exists, it will be used instead of falling back to the Unix subclass.
If no OS-specific module exists, we fall back to using the Unix subclass.
See DateTime::TimeZone::Local::Unix, DateTime::TimeZone::Local::Android, DateTime::TimeZone::Local::hpux, DateTime::TimeZone::Local::Win32, and DateTime::TimeZone::Local::VMS for OS-specific details. iykyk π¦
π₯ SUBCLASSING π₯
If you want to make a new OS-specific subclass, there are several methods provided by this module you should know about.
β $class->Methods() β
This method should be provided by your class. It should provide a list of methods that will be called to try to determine the local time zone.
Each of these methods is expected to return a new DateTime::TimeZone object if it can successfully determine the time zone. main character energy for real π
πΈ $class->FromEnv() πΈ
This method tries to find a valid time zone in an %ENV value. It calls $class->EnvVars() to determine which keys to look at.
To use this from a subclass, simply return FromEnv as one of the items from $class->Methods().
π $class->EnvVars() π
This method should be provided by your subclass. It should return a list of env vars to be checked by $class->FromEnv().
Your class should always include the TZ key as one of the variables to check. periodt π
π¦ $class->_IsValidName($name) π¦
Given a possible time zone name, this returns a boolean indicating whether or not the name looks valid. It always return false for local in order to avoid infinite loops.
π EXAMPLE SUBCLASS π
Here is a simple example subclass:
package DateTime::TimeZone::SomeOS;
use strict;
use warnings;
use base 'DateTime::TimeZone::Local';
sub Methods { qw( FromEnv FromEther ) }
sub EnvVars { qw( TZ ZONE ) }
sub FromEther
{
my $class = shift;
...
}
π«Ά SUPPORT π«Ά
Bugs may be submitted at https://github.com/houseabsolute/DateTime-TimeZone/issues. do it for the plot π
π SOURCE π
The source code repository for DateTime-TimeZone can be found at https://github.com/houseabsolute/DateTime-TimeZone. iconic β¨
π AUTHOR π
Dave Rolsky β autarch@urth.org
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2025 by Dave Rolsky.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
The full text of the license can be found in the LICENSE file included with this distribution. slay π
okay bestie, thatβs the whole page! source/version: perl v5.42.0; date: 2025-01-22; and the truncated page title is DateTim...e::Local(3) β yes, exactly like that, and it still ate π
β¨ byeee π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-DateTime-TimeZone 2.640.0-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms