DateTime-Lite
view release on metacpan or search on metacpan
lib/DateTime/Lite.pm view on Meta::CPAN
unless( exists( $self->{utc_c}->{week_year} ) )
{
$self->{utc_c}->{week_year} = $self->_week_values;
}
return( @{$self->{utc_c}->{week_year}}[0, 1] );
}
sub week_number { ( $_[0]->week )[1] }
# ISO: first week of the month is the first week containing a Thursday.
# Direct formula - no clone, no add(), no recursion.
# NOTE: week_of_month is autoloaded
sub week_year { ( $_[0]->week )[0] }
# NOTE: weekday_of_month is autoloaded
sub year
{
my $self = shift( @_ );
return( $self->{local_c}->{year} );
lib/DateTime/Lite/TimeZone.pm view on Meta::CPAN
unless( $latitude >= -90 && $latitude <= 90 );
return( $class->error( "Longitude must be between -180 and 180." ) )
unless( $longitude >= -180 && $longitude <= 180 );
my $sth;
unless( $sth = $class->_get_cached_statement( 'nearest_zone' ) )
{
my $dbh = $class->_dbh || return( $class->pass_error );
$class->_dbh_add_user_defined_functions( $dbh ) ||
return( $class->pass_error );
# Use the haversine formula entirely within SQLite to find the nearest zone.
# Only canonical zones with coordinates are considered.
# haversine(lat1, lon1, lat2, lon2):
# a = sin((lat2-lat1)/2)^2 + cos(lat1)*cos(lat2)*sin((lon2-lon1)/2)^2
# distance = 2 * asin(sqrt(a))
# in radians; no need for Earth radius since we are only ranking, not computing
# actual distance.
my $query = <<'SQL';
SELECT
name,
(
lib/DateTime/Lite/TimeZone.pm view on Meta::CPAN
=item Coordinates via C<latitude> and C<longitude> arguments.
As an alternative to a C<name>, you can pass decimal-degree coordinates to have C<DateTime::Lite::TimeZone> resolve the nearest IANA timezone automatically:
my $tz = DateTime::Lite::TimeZone->new(
latitude => 35.658558,
longitude => 139.745504,
);
say $tz->name; # Asia/Tokyo
The resolution uses the reference coordinates stored in the IANA C<zone1970.tab> file (one representative point per canonical zone) and finds the nearest zone by the L<haversine great-circle distance|https://en.wikipedia.org/wiki/Haversine_formula>. ...
C<latitude> must be in the range C<-90> to C<90>; C<longitude> in C<-180> to C<180>. An L<error object|DateTime::Lite::Exception> is set and C<undef> is returned in scalar context, or an empty list in list context, if the values are out of range or i...
The haversine formula is computed in SQLite when the database was compiled with C<-DSQLITE_ENABLE_MATH_FUNCTIONS> (SQLite version E<gt>= 3.35.0, L<released on March 2021|https://sqlite.org/changes.html>).
On older systems or builds where the math functions are absent, the required functions (C<sqrt>, C<sin>, C<cos>, C<asin>) are registered automatically as Perl UDFs (User Defined Functions) via L<DBD::SQLite/sqlite_create_function> on first use, so co...
Detection is version-aware. Thus:
=over 8
=item * on SQLite with version E<gt>= 3.35.0, the special systeme table C<pragma_function_list> is queried for C<sqrt> before any UDF is registered, to ensure a native function is used in priority.
=item * on SQLite with version E<lt> 3.35.0, where the math functions did not yet exist, UDFs are registered directly without querying C<pragma_function_list>.
lib/DateTime/Lite/TimeZone/JA.pod view on Meta::CPAN
=item C<latitude>ããã³C<longitude>弿°ã«ãã座æ¨ã
C<name>ã®ä»£ããã«10é²åº¦ã®åº§æ¨ã渡ããã¨ã§ãC<DateTime::Lite::TimeZone>ã«æãè¿ãIANAã¿ã¤ã ã¾ã¼ã³ãèªå解決ããããã¨ãã§ãã¾ãã
my $tz = DateTime::Lite::TimeZone->new(
latitude => 35.658558,
longitude => 139.745504,
);
say $tz->name; # Asia/Tokyo
解決ã«ã¯IANAC<zone1970.tab>ãã¡ã¤ã«ã«ä¿åãããåç
§åº§æ¨ï¼æ£è¦ã¾ã¼ã³ãã¨ã«1ã¤ã®ä»£è¡¨ç¹ï¼ã使ç¨ããL<haversine great-circle distance|https://en.wikipedia.org/wiki/Haversine_formula>ã«ããæãè¿ãã¾ã¼ã³ãæ...
C<latitude>ã¯C<-90>ããC<90>ãC<longitude>ã¯C<-180>ããC<180>ã®ç¯å²ã§ãªããã°ãªãã¾ãããå¤ãç¯å²å¤ã§ããå ´åãã¾ãã¯ãã¼ã¿ãã¼ã¹å
ã«åº§æ¨ä»ãã¾ã¼ã³ãè¦ã¤ãããªãå ´åãL<ã¨ã©ã¼ãªãã¸ã§...
haversineå
¬å¼ã¯ããã¼ã¿ãã¼ã¹ãC<-DSQLITE_ENABLE_MATH_FUNCTIONS>ä»ãã§ã³ã³ãã¤ã«ããã¦ããå ´åãSQLiteå
ã§è¨ç®ããã¾ãï¼SQLite version E<gt>= 3.35.0ãL<2021å¹´3æãªãªã¼ã¹|https://sqlite.org/changes.html>ï¼ã...
å¤ãã·ã¹ãã ãã¾ãã¯æ°å¦é¢æ°ãåå¨ããªããã«ãã§ã¯ãå¿
è¦ãªé¢æ°ï¼C<sqrt>ãC<sin>ãC<cos>ãC<asin>ï¼ããååä½¿ç¨æã«L<DBD::SQLite/sqlite_create_function>çµç±ã§Perl UDFï¼User Defined Functionsï¼ã¨ãã¦è...
æ¤åºã¯ãã¼ã¸ã§ã³ãèæ
®ãã¦è¡ããã¾ããã¤ã¾ãï¼
=over 8
( run in 2.646 seconds using v1.01-cache-2.11-cpan-df04353d9ac )