Metric Time in Tau Station

If you've been following our progress with Tau Station, you know we're creating a science fiction universe in Perl for people to enjoy. As of this writing, the time in Tau Station is 194.10/51:647 GCT.

"GCT" stands for "Galactic Coordinated Time" and that's a variant of metric time. As a software developer, I wish we had that in the real world, but alas, we don't.

The GCT time listed above is roughly 194 years and 10 days after the "Catastrophe" (an apocalyptic event that effectively serves as our "epoch"). There are 100 days in a year, 100 "segments" in a day (14.4 minutes each) and 1000 units in a segment (.864 seconds each).

I love the fact that figuring out the display time for GCT is this simple:

my $days = sprintf "%9.5f" => $seconds_since_catastrophe / $second_in_a_day;
$days =~ m{^(?<year>\d+)(?<day>\d\d)\.(?<segment>\d\d)(?<unit>\d\d\d)}a;
my $gct = "$+{year}.$+{day}/$+{segment}:$+{unit} GCT";

Due to imprecision in normal dates, we don't get an exact round-trip conversion between regular DateTime objects and GCT, but so far we've not found them more than a second off.

Figuring out durations (D0.00/12.500) is similarly simple:

my $days = sprintf "%9.5f" => $duration_in_seconds / 86400;
$days =~ m{^(?<years>\d+)(?<days>\d\d)\.(?<segments>\d\d)(?<units>\d\d\d)}a;
my $duration => "D$+{years}.$+{days}/$+{segments}:$+{units}";

Of course, since that means we often need to know the total number of seconds, we have this nasty bit of code to figure that out:

sub period (%args) {
    my $seconds = delete $args{seconds} // 0;
    $seconds += ( delete $args{minutes}  // 0 ) * 60;
    $seconds += ( delete $args{hours}    // 0 ) * 3600;
    $seconds += ( delete $args{days}     // 0 ) * 86400;

    # solar year
    $seconds += ( delete $args{years}    // 0 ) * 31_556_925.97474;
    $seconds += ( delete $args{units}    // 0 ) * .864;
    $seconds += ( delete $args{segments} // 0 ) * 864;
    if ( keys %args ) {
        my $unknown = join ', ' => sort keys %args;
        croak("Unknown keys to Veure::Util::Time::period: $unknown");
    return round($seconds);

Metric time is lovely and easy. Regular time sucks.

I really wanted to write a DBIx::Class inflator to use GCT objects instead of DateTime objects, but found too many assumptions about the use of DateTime in the DBIx::Class code, so we scrapped that bit. Darn shame.

I hope to see you at FOSDEM in Brussels

I've been rather quiet lately because between building Tau Station and working with some clients, I'm running around faster than a long-tailed cat in a room full of rocking chairs.

I'll be in Brussels for the February 4/5 2017, FOSDEM, talking about Building the Tau Station Universe in Perl. I was planning on giving a talk about testing, but I was specifically asked if I'd talk about Tau Station. While I love the project, I tried to think of a way it wouldn't sound like a 40 minute infomercial at an open source conference.

Woman relaxing in a high-tech hotel room in a space station.
Relaxing in a high-tech hotel room in a space station.

I'm pretty sure I've succeeded and I have to say, I think people are going to be really impressed with some of the code examples. In fact, it's gotten me to the point where I'm having more serious doubts about how object-oriented programming is currently taught. For example, what does the single responsibility principle mean for a combat suit that can pass the Turing test? It serves as armor, and might serve as a weapon, and might serve as a medkit, and even give the soldier a pep-talk.

Single-responsibility my ass.

The Tau Station talk will show a very simple way out of that conundrum.

We have an awesome team working on Tau Station. We've used the same hiring strategy that we use hiring for our clients at All Around the World and it's paid off in spades. You'll be impressed with their work. Fortunately, since this is FOSDEM, even if you can't make it to Brussels, the video will later be online for free and I'll post a link for you.

Hope to see you there!

Update: Once again I have had to close comments due to massive amounts of spam I have to clean out every day.


I don't post as much as I would like to as all my free time is spent working on Tau Station, so I thought I should remind folks that I'm still alive, still hacking on Perl, and still writing obscure technical humor:

ifeq ($(shell whoami), root)
    MESSAGE = "Okay."
    MESSAGE = "What? Make it yourself."


me ::
    - $(NOECHO) echo $(MESSAGE)

a ::
    - $(NOECHO) echo

sandwich ::
    - $(NOECHO) echo

Easily clean up a team's remote git branches

There's a problem that I've seen on every team I've worked with that uses git. Because at Tau Station we're fairly merciless about technical debt--which makes the code base pretty sweet to work with--we take all technical debt issues seriously on the theory that once we launch, it may be too late to clean up (a silly idea in theory, but a prevalent one in practice).

The following technical debt issue is actually causing us a problem, though it's more of a process problem than a technical one:

05:35:02 (master) ~/veure $ git branch -a | wc -l

Wow! We have 272 branches? Most of those are are long merged or abandoned. We've discovered that there are a couple of them which got overlooked (I'm tempted to blame github's poor PM tooling, but it's a lousy craftsman who blames his tools). We tried asking devs to find all of their remote branches and review them and delete them, but that turned out to be a rather daunting task and they're still missing branches.

Now, with a simple Perl script, we have a solution.

Seeing the SQL in DBIx::Class

There's no question that DBIx::Class is the dominant ORM in Perl. That's because it's fast, it's flexible, and sane. Well, mostly sane, until you need some introspection (if anyone knows a better way to do this, I'm all ears!):

sub _get_json_columns ( $self, $schema_class ) {
    state $json_columns_for = {};
    unless ( exists $json_columns_for->{$schema_class} ) {
        my $columns = $self->schema->resultset($schema_class)
          = [ grep { 'json' eq $columns->{$_}{data_type} } keys %$columns ];
    return $json_columns_for->{$schema_class};

But what's terribly frustrating to many devs is getting DBIx::Class to show the queries it's executing, along with the bind parameters (one without the other is often useless).

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book!