🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉
Avatar of suyuxp

suyuxp's solution

to Gigasecond in the Crystal Track

Published at Aug 24 2020 · 0 comments
Test suite

Given a moment, determine the moment that would be after a gigasecond has passed.

A gigasecond is 10^9 (1,000,000,000) seconds.


Follow the setup instructions for Crystal here:


More help installing can be found here:


Making the Test Suite Pass

Execute the tests with:

$ crystal spec

In each test suite all but the first test have been skipped.

Once you get a test passing, you can unskip the next one by changing pending to it.


Chapter 9 in Chris Pine's online Learn to Program tutorial. http://pine.fm/LearnToProgram/?Chapter=09

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


require "spec"
require "../src/*"

describe "Gigasecond" do
  describe "#from" do
    it "finds gigsecond from 2011_04_25" do
      result = Gigasecond.from(Time.utc(2011, 4, 25, 0, 0, 0))
      result.should eq Time.utc(2043, 1, 1, 1, 46, 40)

    pending "finds gigsecond from 1977_06_13" do
      result = Gigasecond.from(Time.utc(1977, 6, 13, 0, 0, 0))
      result.should eq Time.utc(2009, 2, 19, 1, 46, 40)

    pending "finds gigsecond from 1959_07_19" do
      result = Gigasecond.from(Time.utc(1959, 7, 19, 0, 0, 0))
      result.should eq Time.utc(1991, 3, 27, 1, 46, 40)

    pending "finds gigsecond with full_time specified" do
      result = Gigasecond.from(Time.utc(2015, 1, 24, 22, 0, 0))
      result.should eq Time.utc(2046, 10, 2, 23, 46, 40)

    pending "finds gigsecond with full_time with day rollover" do
      result = Gigasecond.from(Time.utc(2015, 1, 24, 23, 59, 59))
      result.should eq Time.utc(2046, 10, 3, 1, 46, 39)

    pending "test_with_your_birthday" do
module Gigasecond
    def self.from(from)
        from + 1_000_000_000.seconds

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?