acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
posix_time.h
1// Created by camilo on 2023-07-04 18:43 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5struct posix_time_t {};
6
7struct CLASS_DECL_ACME posix_time
8{
9
10 ::i64 m_iSecond;
11
12 constexpr posix_time() : m_iSecond(0) {}
13 constexpr posix_time(no_initialize_t) {}
14 constexpr posix_time(zero_t) : m_iSecond(0) {}
15 template < prototype_integral INTEGRAL >
16 constexpr posix_time(posix_time_t, INTEGRAL iSecond) : m_iSecond(iSecond) {}
17 constexpr posix_time(const posix_time &) = default;
18 explicit posix_time(const ::file_time & pfile_time, ::i32 nDST = -1);
19 explicit posix_time(const system_time & systemtime, ::i32 nDST = -1);
20 explicit posix_time(const ::earth::gregorian_time & gregoriantime);
21 posix_time(now_t);
22
23 constexpr posix_time operator + (posix_time posixtime) const
24 {
25 return { posix_time_t{}, m_iSecond + posixtime.m_iSecond };
26 }
27
28 constexpr posix_time operator - (posix_time posixtime) const
29 {
30 return { posix_time_t{}, m_iSecond - posixtime.m_iSecond };
31 }
32
33 constexpr posix_time & operator += (posix_time posixtime)
34 {
35 m_iSecond += posixtime.m_iSecond;
36 return *this;
37 }
38
39 constexpr posix_time & operator -=(posix_time posixtime)
40 {
41 m_iSecond -= posixtime.m_iSecond;
42 return *this;
43 }
44
45 constexpr posix_time & operator =(const posix_time & posixtime)
46 {
47 m_iSecond = posixtime.m_iSecond;
48 return *this;
49 }
50
51
52 template < prototype_integral INTEGRAL >
53 constexpr posix_time & operator *=(INTEGRAL i)
54 {
55 m_iSecond *= i;
56 return *this;
57 }
58
59
60 template < prototype_integral INTEGRAL >
61 constexpr posix_time & operator /=(INTEGRAL i)
62 {
63 m_iSecond /= i;
64 return *this;
65 }
66
67
68 template < prototype_integral INTEGRAL >
69 constexpr posix_time & operator %=(INTEGRAL i)
70 {
71 m_iSecond %= i;
72 return *this;
73 }
74
75
76 template < prototype_integral INTEGRAL >
77 constexpr posix_time operator * (INTEGRAL i) const
78 {
79 return { posix_time_t{}, m_iSecond * i };
80 }
81
82
83 template < prototype_integral INTEGRAL >
84 constexpr posix_time operator / (INTEGRAL i) const
85 {
86 return { posix_time_t{}, m_iSecond / i };
87 }
88
89
90 template < prototype_integral INTEGRAL >
91 constexpr posix_time operator % (INTEGRAL i) const
92 {
93 return { posix_time_t{}, m_iSecond % i };
94 }
95
96
97 bool operator ==(const ::posix_time & time) const
98 {
99
100 return m_iSecond == time.m_iSecond;
101
102 }
103
104 std::strong_ordering operator <=>(const ::posix_time & time) const
105 {
106
107 return m_iSecond <=> time.m_iSecond;
108
109 }
110
111 inline static posix_time now() { return now_t{}; }
112
113 constexpr ::i64 minutes() const;
114 constexpr ::i64 hours() const;
115 constexpr ::i64 days() const;
116
117};
118
119
120template < prototype_integral INTEGRAL >
121constexpr posix_time operator * (INTEGRAL i, const ::posix_time & time)
122{
123 return { posix_time_t{}, i * time.m_iSecond };
124}
125
126
127constexpr posix_time operator""_posix_time(::u64 u) {
128 return { posix_time_t{}, u };
129}
130
131
132
Definition system_time.h:8
Definition aaa_time.h:13
Definition _tags.h:5
Definition _structures.h:48
Definition posix_time.h:5
Definition posix_time.h:8
Definition _structures.h:50