Skip to content

Instantly share code, notes, and snippets.

@jacoby
Last active December 14, 2015 19:09
Show Gist options
  • Select an option

  • Save jacoby/5134618 to your computer and use it in GitHub Desktop.

Select an option

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
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