Skip to content

Commit 42b0ff2

Browse files
Sync gigasecond (#1319)
1 parent d76d659 commit 42b0ff2

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

exercises/practice/gigasecond/.meta/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
},
2121
"blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.",
2222
"source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.",
23-
"source_url": "http://pine.fm/LearnToProgram/?Chapter=09"
23+
"source_url": "https://pine.fm/LearnToProgram/?Chapter=09"
2424
}

exercises/practice/gigasecond/.meta/tests.toml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[92fbe71c-ea52-4fac-bd77-be38023cacf7]
613
description = "date only specification of time"
@@ -16,3 +23,6 @@ description = "full time specified"
1623

1724
[09d4e30e-728a-4b52-9005-be44a58d9eba]
1825
description = "full time with day roll-over"
26+
27+
[fcec307c-7529-49ab-b0fe-20309197618a]
28+
description = "does not mutate the input"

exercises/practice/gigasecond/gigasecond.test.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
import { Gigasecond } from './gigasecond'
22

33
describe('Gigasecond', () => {
4-
it('tells a gigasecond anniversary since midnight', () => {
5-
const gs = new Gigasecond(new Date(Date.UTC(2015, 8, 14)))
6-
const expectedDate = new Date(Date.UTC(2047, 4, 23, 1, 46, 40))
4+
it('date only specification of time', () => {
5+
const gs = new Gigasecond(new Date(Date.parse('2011-04-25')))
6+
const expectedDate = new Date(Date.parse('2043-01-01T01:46:40Z'))
77
expect(gs.date()).toEqual(expectedDate)
88
})
99

10-
xit('tells the anniversary is next day when you are born at night', () => {
11-
const gs = new Gigasecond(new Date(Date.UTC(2015, 8, 14, 23, 59, 59)))
12-
const expectedDate = new Date(Date.UTC(2047, 4, 24, 1, 46, 39))
10+
xit('second test for date only specification of time', () => {
11+
const gs = new Gigasecond(new Date(Date.parse('1977-06-13')))
12+
const expectedDate = new Date(Date.parse('2009-02-19T01:46:40Z'))
1313
expect(gs.date()).toEqual(expectedDate)
1414
})
1515

16-
xit('even works before 1970 (beginning of Unix epoch )', () => {
17-
const gs = new Gigasecond(new Date(Date.UTC(1959, 6, 19, 5, 13, 45)))
18-
const expectedDate = new Date(Date.UTC(1991, 2, 27, 7, 0, 25))
16+
xit('third test for date only specification of time', () => {
17+
const gs = new Gigasecond(new Date(Date.parse('1959-07-19')))
18+
const expectedDate = new Date(Date.parse('1991-03-27T01:46:40Z'))
1919
expect(gs.date()).toEqual(expectedDate)
2020
})
2121

22-
xit('make sure calling "date" doesn\'t mutate value', () => {
23-
const gs = new Gigasecond(new Date(Date.UTC(1959, 6, 19, 5, 13, 45)))
24-
const expectedDate = new Date(Date.UTC(1991, 2, 27, 7, 0, 25))
22+
xit('full time specified', () => {
23+
const gs = new Gigasecond(new Date(Date.parse('2015-01-24T22:00:00Z')))
24+
const expectedDate = new Date(Date.parse('2046-10-02T23:46:40Z'))
25+
expect(gs.date()).toEqual(expectedDate)
26+
})
27+
28+
xit('full time with day roll-over', () => {
29+
const gs = new Gigasecond(new Date(Date.parse('2015-01-24T23:59:59Z')))
30+
const expectedDate = new Date(Date.parse('2046-10-03T01:46:39Z'))
31+
expect(gs.date()).toEqual(expectedDate)
32+
})
33+
34+
xit('does not mutate the input', () => {
35+
const gs = new Gigasecond(new Date(Date.parse('2015-01-24T23:59:59Z')))
36+
const expectedDate = new Date(Date.parse('2046-10-03T01:46:39Z'))
2537
gs.date()
2638
expect(gs.date()).toEqual(expectedDate)
2739
})

0 commit comments

Comments
 (0)