# whizdom's solution

## to Gigasecond in the Crystal Track

Published at Jun 03 2019 · 0 comments
Instructions
Test suite
Solution

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

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

## Setup

Follow the setup instructions for Crystal here:

http://exercism.io/languages/crystal

More help installing can be found here:

http://crystal-lang.org/docs/installation/index.html

## 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`.

## Source

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.

### gigasecond_spec.cr

``````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)
end

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

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

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

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

pending "test_with_your_birthday" do
end
end
end``````
``````class Gigasecond
GIGASECOND = 1_000_000_000.seconds

# Finds Gigasecond from the given time
def self.from(time)
time + GIGASECOND
end
end``````