File: datetime.h

package info (click to toggle)
angelscript 2.35.1%2Bds-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,388 kB
  • sloc: cpp: 71,969; asm: 1,558; makefile: 665; xml: 214; javascript: 42; ansic: 22; python: 22; sh: 7
file content (61 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef SCRIPTDATETIME_H
#define SCRIPTDATETIME_H

#ifndef ANGELSCRIPT_H 
// Avoid having to inform include path if header is already include before
#include <angelscript.h>
#endif

#ifdef AS_CAN_USE_CPP11
#include <chrono>
#else
#error Sorry, this requires C++11 which your compiler doesnt appear to support
#endif

BEGIN_AS_NAMESPACE

class CDateTime
{
public:
	// Constructors
	CDateTime();
	CDateTime(const CDateTime &other);
	CDateTime(asUINT year, asUINT month, asUINT day, asUINT hour, asUINT minute, asUINT second);

	// Copy the stored value from another any object
	CDateTime &operator=(const CDateTime &other);

	// Accessors
	asUINT getYear() const;
	asUINT getMonth() const;
	asUINT getDay() const;
	asUINT getHour() const;
	asUINT getMinute() const;
	asUINT getSecond() const;

	// Setters
	// Returns true if valid
	bool setDate(asUINT year, asUINT month, asUINT day);
	bool setTime(asUINT hour, asUINT minute, asUINT second);

	// Operators
	// Return difference in seconds
	asINT64          operator-(const CDateTime &other) const;
	CDateTime        operator+(asINT64 seconds) const;
	friend CDateTime operator+(asINT64 seconds, const CDateTime &other);
	CDateTime &      operator+=(asINT64 seconds);
	CDateTime        operator-(asINT64 seconds) const;
	friend CDateTime operator-(asINT64 seconds, const CDateTime &other);
	CDateTime &      operator-=(asINT64 seconds);
	bool             operator==(const CDateTime &other) const;
	bool             operator<(const CDateTime &other) const;

protected:
	std::chrono::system_clock::time_point tp;
};

void RegisterScriptDateTime(asIScriptEngine *engine);

END_AS_NAMESPACE

#endif