summaryrefslogtreecommitdiffstats
path: root/util/datetime/base.pxd
blob: ea60eb769d488b9fb8829610ffebed892d9f1b96 (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from libc.stdint cimport uint32_t
from libc.stdint cimport uint64_t
from libcpp cimport bool as bool_t
from posix.types cimport time_t

from util.generic.string cimport TString, TStringBuf


cdef extern from "<util/datetime/base.h>" nogil:

    cdef cppclass TTimeBase:
        TTimeBase()
        TTimeBase(uint64_t)

        uint64_t GetValue()
        double SecondsFloat()
        uint64_t GetMicroSeconds "TTimeBase::MicroSeconds" ()
        uint64_t GetMilliSeconds "TTimeBase::MilliSeconds" ()
        uint64_t GetSeconds "TTimeBase::Seconds" ()
        uint64_t GetMinutes "TTimeBase::Minutes" ()
        uint64_t GetHours "TTimeBase::Hours" ()
        uint64_t GetDays "TTimeBase::Days" ()
        uint64_t GetNanoSeconds "TTimeBase::NanoSeconds" ()
        uint32_t GetMicroSecondsOfSecond "TTimeBase::MicroSecondsOfSecond" ()
        uint32_t GetMilliSecondsOfSecond "TTimeBase::MilliSecondsOfSecond" ()
        uint32_t GetNanoSecondsOfSecond "TTimeBase::NanoSecondsOfSecond"()


    cdef cppclass TInstant(TTimeBase):
        TInstant()
        TInstant(uint64_t)

        @staticmethod
        TInstant Now() except +
        @staticmethod
        TInstant Max()
        @staticmethod
        TInstant Zero()
        @staticmethod
        TInstant MicroSeconds(uint64_t)
        @staticmethod
        TInstant MilliSeconds(uint64_t)
        @staticmethod
        TInstant Seconds(uint64_t)
        @staticmethod
        TInstant Minutes(uint64_t)
        @staticmethod
        TInstant Hours(uint64_t)
        @staticmethod
        TInstant Days(uint64_t)

        time_t TimeT()

        TString ToString() except +
        TString ToStringUpToSeconds() except +
        TString ToStringLocal() except +
        TString ToStringLocalUpToSeconds() except +
        TString FormatLocalTime(const char*)
        TString FormatGmTime(const char* format)

        @staticmethod
        TInstant ParseIso8601(const TStringBuf) except +
        @staticmethod
        TInstant ParseRfc822(const TStringBuf) except +
        @staticmethod
        TInstant ParseHttp(const TStringBuf) except +
        @staticmethod
        TInstant ParseX509Validity(const TStringBuf) except +

        @staticmethod
        bool_t TryParseIso8601(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseRfc822(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseHttp(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseX509(const TStringBuf, TInstant&) except +

        @staticmethod
        TInstant ParseIso8601Deprecated(const TStringBuf) except +
        @staticmethod
        TInstant ParseRfc822Deprecated(const TStringBuf) except +
        @staticmethod
        TInstant ParseHttpDeprecated(const TStringBuf) except +
        @staticmethod
        TInstant ParseX509ValidityDeprecated(const TStringBuf) except +

        @staticmethod
        bool_t TryParseIso8601Deprecated(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseRfc822Deprecated(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseHttpDeprecated(const TStringBuf, TInstant&) except +
        @staticmethod
        bool_t TryParseX509Deprecated(const TStringBuf, TInstant&) except +


    cdef cppclass TDuration(TTimeBase):
        TDuration()
        TDuration(uint64_t)

        @staticmethod
        TDuration MicroSeconds(uint64_t)

        TInstant ToDeadLine() except +
        TInstant ToDeadLine(TInstant) except +

        @staticmethod
        TDuration Max()
        @staticmethod
        TDuration Zero()
        @staticmethod
        TDuration Seconds(uint64_t)
        @staticmethod
        TDuration Minutes(uint64_t)
        @staticmethod
        TDuration Hours(uint64_t)
        @staticmethod
        TDuration Days(uint64_t)

        @staticmethod
        TDuration Parse(const TStringBuf)
        @staticmethod
        bool_t TryParse(const TStringBuf, TDuration&)

        TString ToString() except +