WWW::Google::Time - Perl 6 module to get time for various locations using Google
use WWW::Google::Time; my %time = google-time-in 'Toronto'; say "Time in %time<where> is %time<str>"; # Prints: Time in Toronto, ON is 9:25 AM EST, Monday, December 7, 2015 # Full version: say qq:to/END/ Location: %time<where> Time: %time<time> Time zone: %time<tz> Day of the week: %time<week-day> Month: %time<month> Day of the month: %time<month-day> Year: %time<year> Full time string: %time<str> DateTime object: %time<DateTime> END # Prints: # Location: Toronto, ON # Time: 9:31 AM # Time zone: EST # Day of the week: Monday # Month: December # Day of the month: 7 # Year: 2015 # Full time string: 9:31 AM EST, Monday, December 7, 2015 # DateTime object: 2016-12-22T09:31:48.651773-05:00
This module lets you find out the current time in various locations around the globe using Google.
my %time = google-time-in 'Toronto';
Uses Google to fetch time for specified location. Will fail if a network error occurs or if the location cannot be found. On success, returns a hash with the following keys:
# Location: Toronto, ON say "Location: %time<where>"
The location for which the time data is provided. Note this might be slightly
different from the original location you provided to
# Time: 9:31 AM say "Time: %time<time>"
The current time in
# Time zone: EST say "Time zone: %time<tz>"
The time zone.
# Day of the week: Monday say "Day of the week: %time<week-day>"
# Month: December say "Month: %time<month>"
The name of the month.
# Day of the month: 7 say "Day of the month: %time<month-day>"
The day of the month (1–31).
# Year: 2015 say "Year: %time<year>"
# Full time string: 9:31 AM EST, Monday, December 7, 2015 say "Full time string: %time<str>"
Convenience key that combines most of the above keys into a single human-readable string.
# DateTime object: 2016-12-22T09:31:48.651773-05:00 say "DateTime object: %time<DateTime>";
representing the time. Since seconds are not available from Google, the seconds
in the object are set via
59.999 min DateTime.now.utc.second and thus depend
on the local time of the machine the code is running on.
Note: the timezone offset is derived from a hardcoded map of timezone abbreviation-to-offset and if the abbreviation cannot be decoded, offset of 0 is used. I have no guarantees that map includes every possible timezone abbreviation Google may return.
Google's Terms of Service: https://www.google.com/intl/en/policies/terms/
Fork this module on GitHub: https://github.com/zoffixznet/perl6-WWW-Google-Time
To report bugs or request features, please use https://github.com/zoffixznet/perl6-WWW-Google-Time/issues
Zoffix Znet (http://zoffix.com/)
You can use and distribute this module under the terms of the
The Artistic License 2.0. See the
LICENSE file included in this
distribution for complete details.