Debian Codegraph @

lib/DateTime/TimeZone/Local/Android.pm

raw
1 package DateTime::TimeZone::Local::Android;
2
3 use strict;
4 use warnings;
5 use namespace::autoclean;
6
7 our $VERSION = '2.69';
8
9 use Try::Tiny;
10
11 use parent 'DateTime::TimeZone::Local';
12
13 sub Methods {
14 return qw(
15 FromEnv
16 FromGetProp
17 FromDefault
18 );
19 }
20
21 sub EnvVars { return 'TZ' }
22
23 # https://chromium.googlesource.com/native_client/nacl-bionic/+/upstream/master/libc/tzcode/localtime.c
24 sub FromGetProp {
25 ## no critic (InputOutput::ProhibitBacktickOperators)
26 my $name = `getprop persist.sys.timezone`;
27 chomp $name;
28 my $tz = try {
29 ## no critic (Variables::RequireInitializationForLocalVars)
30 local $SIG{__DIE__};
31 DateTime::TimeZone->new( name => $name );
32 };
33
34 return $tz if $tz;
35 }
36
37 # See the link above. Android always defaults to UTC
38 sub FromDefault {
39 return try {
40 ## no critic (Variables::RequireInitializationForLocalVars)
41 local $SIG{__DIE__};
42 DateTime::TimeZone->new( name => 'UTC' );
43 };
44 }
45
46 1;