1#!/usr/bin/perl
2use strict;
3use warnings;
4
5use Time::Moment;
6
7# Converts the given moment to Swatch Internet Time (beat time).
8# http://www.swatch.com/en/internet-time
9# https://en.wikipedia.org/wiki/Swatch_Internet_Time
10sub moment_to_beat {
11    @_ == 1 or die q/Usage: moment_to_beat(moment)/;
12    my ($tm) = @_;
13
14    # Biel Meantime (BMT) is UTC+1
15    my $rd = $tm->with_offset_same_instant(1*60)
16                ->rd;
17    return ($rd - int $rd) * 1E3;
18}
19
20my $tm = Time::Moment->now;
21printf "@%3.3f\n", moment_to_beat($tm);
22