Last active
December 14, 2015 19:09
-
-
Save jacoby/5134618 to your computer and use it in GitHub Desktop.
Beats.pm, a quick and dirty module to convert times to Swatch Internet Time. http://en.wikipedia.org/wiki/Swatch_Internet_Time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Beats ; | |
| use strict ; | |
| use warnings ; | |
| use Exporter qw(import) ; | |
| use DateTime ; | |
| our $VERSION = 0.0.1 ; | |
| our @EXPORT = qw( time_in_beats ) ; | |
| sub time_in_beats { | |
| my ( $time ) = shift ; | |
| if ( !$time ) { | |
| $time = DateTime->now() ; | |
| } | |
| $time->set_time_zone( 'Africa/Lagos' ) ; | |
| my $hour = $time->hour() ; | |
| my $minute = $time->minute() ; | |
| my $second = $time->second() ; | |
| my $beats = ( $hour * 3600 + $minute * 60 + $second ) / 86.4; | |
| return sprintf '%.2f' , $beats ; | |
| } | |
| # Lagos, Nigeria follows West Africa Time. | |
| # West Africa Time (WAT) == Central Europe Time (CET) except no DST, | |
| # and Swatch Internet Time also does not observe DST. | |
| '1' ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment