App-TimeZoneUtils

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

            "Test::Pod" : "1.41",
            "Test::Pod::Coverage" : "1.08",
            "Test::Rinci" : "0.151"
         },
         "x_spec" : {
            "Rinci" : "v1.1.96"
         }
      },
      "runtime" : {
         "requires" : {
            "DateTime" : "0",
            "DateTime::TimeZone" : "0",
            "Perinci::CmdLine::Any" : "0.152",
            "Perinci::CmdLine::Lite" : "1.905",
            "perl" : "5.010001",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "File::Spec" : "0",

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: App-TimeZoneUtils
provides:
  App::TimeZoneUtils:
    file: lib/App/TimeZoneUtils.pm
    version: '0.001'
requires:
  DateTime: '0'
  DateTime::TimeZone: '0'
  Perinci::CmdLine::Any: '0.152'
  Perinci::CmdLine::Lite: '1.905'
  perl: '5.010001'
  strict: '0'
  warnings: '0'
resources:
  bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=App-TimeZoneUtils
  homepage: https://metacpan.org/release/App-TimeZoneUtils
  repository: git://github.com/perlancar/perl-App-TimeZoneUtils.git
version: '0.001'

Makefile.PL  view on Meta::CPAN

    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-TimeZoneUtils",
  "EXE_FILES" => [
    "script/detect-local-time-zone"
  ],
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.010001",
  "NAME" => "App::TimeZoneUtils",
  "PREREQ_PM" => {
    "DateTime" => 0,
    "DateTime::TimeZone" => 0,
    "Perinci::CmdLine::Any" => "0.152",
    "Perinci::CmdLine::Lite" => "1.905",
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "File::Spec" => 0,
    "IO::Handle" => 0,
    "IPC::Open3" => 0,
    "Test::More" => 0
  },
  "VERSION" => "0.001",
  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "DateTime" => 0,
  "DateTime::TimeZone" => 0,
  "File::Spec" => 0,
  "IO::Handle" => 0,
  "IPC::Open3" => 0,
  "Perinci::CmdLine::Any" => "0.152",
  "Perinci::CmdLine::Lite" => "1.905",
  "Test::More" => 0,
  "strict" => 0,
  "warnings" => 0
);

README  view on Meta::CPAN

    *   detect-local-time-zone

FUNCTIONS
  detect_local_time_zone
    Usage:

     detect_local_time_zone() -> [$status_code, $reason, $payload, \%result_meta]

    Detect local time zone.

    Currently uses DateTime::TimeZone, which has several heuristics itself
    (please see the module for more details). When local time zone cannot be
    determined, it dies.

    This function is not exported.

    No arguments.

    Returns an enveloped result (an array).

    First element ($status_code) is an integer containing HTTP-like status

dist.ini  view on Meta::CPAN


[InsertExecsList]

[@Author::PERLANCAR]
:version=0.605

[Prereqs]
perl=5.010001
strict=0
warnings=0
DateTime=0
DateTime::TimeZone=0

[Prereqs / DevelopX_spec]
-phase=develop
-relationship=x_spec
Rinci=1.1.96

lib/App/TimeZoneUtils.pm  view on Meta::CPAN

our $DIST = 'App-TimeZoneUtils'; # DIST
our $VERSION = '0.001'; # VERSION

our %SPEC;

$SPEC{detect_local_time_zone} = {
    v => 1.1,
    summary => 'Detect local time zone',
    description => <<'_',

Currently uses <pm:DateTime::TimeZone>, which has several heuristics itself
(please see the module for more details). When local time zone cannot be
determined, it dies.

_
    args => {
    },
    examples => [
    ],
};
sub detect_local_time_zone {
    require DateTime;
    require DateTime::TimeZone;
    my %args = @_;

    my $tz = DateTime::TimeZone->new(name => "local");
    my $dt = DateTime->now(time_zone => "UTC");
    my $offset_in_seconds = $tz->offset_for_datetime($dt);
    my $offset_abs = abs($offset_in_seconds);
    my $offset_sign = $offset_in_seconds > 0 ? "+" : "-";
    my $offset_h = int($offset_abs / 3600);
    my $offset_m = int(($offset_abs - $offset_h*3600)/60);
    my $offset_in_hhmm = sprintf(
        "%s%02d%02d", $offset_sign, $offset_h, $offset_m);
    [200, "OK", {
        name => $tz->name,
        offset_in_seconds => $offset_in_seconds,

lib/App/TimeZoneUtils.pm  view on Meta::CPAN



=head2 detect_local_time_zone

Usage:

 detect_local_time_zone() -> [$status_code, $reason, $payload, \%result_meta]

Detect local time zone.

Currently uses L<DateTime::TimeZone>, which has several heuristics itself
(please see the module for more details). When local time zone cannot be
determined, it dies.

This function is not exported.

No arguments.

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code

script/detect-local-time-zone  view on Meta::CPAN

This document describes version 0.001 of detect-local-time-zone (from Perl distribution App-TimeZoneUtils), released on 2021-09-06.

=head1 SYNOPSIS

Usage:

% B<detect-local-time-zone> [B<--format>=I<name>|B<--json>] [B<--(no)naked-res>] [B<--page-result>[=I<program>]|B<--view-result>[=I<program>]]

=head1 DESCRIPTION

Currently uses L<DateTime::TimeZone>, which has several heuristics itself
(please see the module for more details). When local time zone cannot be
determined, it dies.

=head1 OPTIONS

C<*> marks required options.

=head2 Output options

=over



( run in 0.351 second using v1.01-cache-2.11-cpan-05444aca049 )