Exercism v3 launches on Sept 1st 2021. Learn more! ๐Ÿš€๐Ÿš€๐Ÿš€
Avatar of The-F00L

The-F00L's solution

to Gigasecond in the CFML Track

Published at Apr 12 2021 · 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.

To run the code in this exercise, you will only need to have CommandBox CLI installed. This binary runs CFML code from the command line.

To run the tests, cd into the exercise folder and run the following:

box task run TestRunner
# Or start up a test watcher that will rerun when files change
box task run TestRunner --:watcher

The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the BDD style which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:



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.


component extends="testbox.system.BaseSpec" {

	function beforeAll(){
	  SUT = createObject( 'Gigasecond' );

	function run(){
		describe( "My Gigasecond class", function(){			

			describe( 'Add one gigasecond to the input.', function(){

				it( 'date only specification of time', function(){
					expect( SUT.add( birthdate='2011-04-25' ) ).toBe( '2043-01-01T01:46:40' );

				it( 'second test for date only specification of time', function(){
					expect( SUT.add( birthdate='1977-06-13' ) ).toBe( '2009-02-19T01:46:40' );

				it( 'third test for date only specification of time', function(){
					expect( SUT.add( birthdate='1959-07-19' ) ).toBe( '1991-03-27T01:46:40' );

				it( 'full time specified', function(){
					expect( SUT.add( birthdate='2015-01-24T22:00:00' ) ).toBe( '2046-10-02T23:46:40' );

				it( 'full time with day roll-over', function(){
					expect( SUT.add( birthdate='2015-01-24T23:59:59' ) ).toBe( '2046-10-03T01:46:39' );




component extends="GigasecondTest" {

	function beforeAll(){
	  SUT = createObject( 'Solution' );

* Your implmentation of the Gigasecond exercise
component {
	* @returns 
	 function add( birthdate ) {
		return dateAdd('s' , 10^9, birthdate);

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?