Skip to content

Giga Second

Intro

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

Task

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

The Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#include <boost/date_time/posix_time/ptime.hpp>
#include <string>
#if !defined(GIGASECOND_H)
#define GIGASECOND_H
#include <boost/date_time/posix_time/ptime.hpp>

namespace gigasecond {
boost::posix_time::ptime advance(boost::posix_time::ptime test);
} // namespace gigasecond

#endif // GIGASECOND_H
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include "gigasecond.h"
#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/posix_time/time_parsers.hpp>

namespace gigasecond {
boost::posix_time::ptime advance(boost::posix_time::ptime test);
} // namespace gigasecond

boost::posix_time::ptime gigasecond::advance(boost::posix_time::ptime test) {
  return test+=boost::posix_time::seconds(1000000000);
}

Last update: February 8, 2021

Comments