File: Timestamp.h

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (40 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "Timespan.h"
#include "Printable.h"

class Timespan;

/**
 * Represents a timestamp relative to some date. Eg. January 1, 1601. This
 * is assumed to be stable between different runs of the program. For high
 * performance timing that is not 'stable', look at Clock/Time (TODO).
 * The internal time is measured in us, but it is only accurate
 * to a few milliseconds (on Windows).
 */
class Timestamp : public Printable {
public:
	Timestamp(); // Creates a time "now".
	Timestamp(nat64 t);

	// measured in us.
	nat64 time;

	inline bool operator ==(const Timestamp &other) const { return time == other.time; }
	inline bool operator !=(const Timestamp &other) const { return time != other.time; }
	bool operator >(const Timestamp &other) const;
	bool operator <(const Timestamp &other) const;
	bool operator >=(const Timestamp &other) const;
	bool operator <=(const Timestamp &other) const;

	Timespan operator -(const Timestamp &other) const;
	Timestamp operator +(const Timespan &other) const;
	Timestamp operator -(const Timespan &other) const;
	Timestamp &operator +=(const Timespan &other);
	Timestamp &operator -=(const Timespan &other);

	friend class Timespan;
protected:

	virtual void output(std::wostream &to) const;
};