DUDS
Distributed Update of Data from Something
Interstellar.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
12 #include <duds/data/Int128.hpp>
13 #include <iomanip>
14 
15 namespace duds { namespace time { namespace interstellar {
16 
17 std::ostream &operator << (std::ostream &os, const Metricform &m) {
18  char f = os.fill();
19  if (m.neg) {
20  os << '-';
21  }
22  os << m.G << std::setfill('0') << std::right << "G " << std::setw(3) << m.M
23  << "M " << std::setw(3) << m.k << "k " << std::setw(3) << m.s << 's' <<
24  std::setfill(f) << std::left;
25  return os;
26 }
27 
28 std::ostream &operator << (std::ostream &os, const Hectoform &h) {
29  char f = os.fill();
30  if (h.neg) {
31  os << '-';
32  }
33  os << h.e10 << std::setfill('0') << std::right << ':' << std::setw(2) <<
34  h.e8 << ':' << std::setw(2) << h.M << '-' << std::setw(2) << h.ma << ':' <<
35  std::setw(2) << h.h << ':' << std::setw(2) << h.s << std::setfill(f) <<
36  std::left;
37  return os;
38 }
39 
40 const duds::data::int128_t OneE6(1000000L);
41 const duds::data::int128_t OneE12(1000000000000L);
42 const duds::data::int128_t OneE15(1000000000000000L);
43 
44 } } }
unsigned int k
Kiloseconds field.
Definition: Metricform.hpp:41
unsigned int G
Gigaseconds field.
Definition: Metricform.hpp:29
unsigned int neg
The negative flag.
Definition: Metricform.hpp:51
boost::multiprecision::int128_t int128_t
The type used for 128-bit integers.
Definition: Int128.hpp:66
unsigned int e8
1e8 seconds field.
Definition: Hectoform.hpp:37
unsigned int ma
Myriaseconds field.
Definition: Hectoform.hpp:50
Holds Interstellar Time down to seconds in fields that increase by a power of 1000, three decimal digits each, up to a gigaseconds field.
Definition: Metricform.hpp:23
const int128_t OneE15
1e15 in a 128-bit integer.
128-bit integer support.
Holds Interstellar Time down to seconds in fields that increase by a power of 100, two decimal digits each, up to a 1e10 seconds field.
Definition: Hectoform.hpp:25
std::ostream & operator<<(std::ostream &os, const Hectoform &h)
Writes the Hectoform time in its Human readable format in plain text.
unsigned int s
Seconds field.
Definition: Hectoform.hpp:60
unsigned int e10
1e10 seconds field.
Definition: Hectoform.hpp:31
unsigned int neg
The negative flag.
Definition: Hectoform.hpp:66
unsigned int M
Megaseconds field.
Definition: Metricform.hpp:35
unsigned int h
Hectoseconds field.
Definition: Hectoform.hpp:56
unsigned int s
Seconds field.
Definition: Metricform.hpp:45
unsigned int M
Megaseconds field.
Definition: Hectoform.hpp:43
const int128_t OneE12
1e12 in a 128-bit integer.
const int128_t OneE6
1e6 in a 128-bit integer.