OnixS C++ eSpeed ITCH Market Data Handler 1.7.3
API documentation
Loading...
Searching...
No Matches
Timestamp.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
21#include <string>
22
25
26namespace OnixS { namespace HandlerCore { namespace Common { struct TimeHelper; }}}
27
29
51
53struct ONIXS_ESPEED_ITCH_API YearMonthDay
54{
56 unsigned year;
57
60
62 unsigned day;
63};
64
66struct ONIXS_ESPEED_ITCH_API TimestampFormat
67{
82};
83
86typedef UInt64 RawTimestamp;
87
89class ONIXS_ESPEED_ITCH_API Timestamp
90{
91 public:
94
97 unsigned int year, Month::Enum month, unsigned int day,
98 unsigned int hour = 0, unsigned int minute = 0, unsigned int second = 0,
99 unsigned int nanosecond = 0);
100
104 explicit
106
108 unsigned year() const;
109
112
115 unsigned int day() const;
116
118 void date (YearMonthDay&) const;
119
122 unsigned int hour() const;
123
126 unsigned int minute() const;
127
130 unsigned int second() const;
131
134 unsigned int millisecond() const;
135
138 unsigned int microsecond() const;
139
142 unsigned int nanosecond() const;
143
145 const TimeSpan& sinceEpoch() const;
146
148 static Timestamp epoch();
149
151 bool operator == (const Timestamp&) const;
152
154 bool operator != (const Timestamp&) const;
155
157 bool operator < (const Timestamp&) const;
158
161 std::string
162 toString (
165
168 void
170 std::string& str,
173
179
184 static Timestamp now();
185
188 static
191 const std::string&,
194
196 static
199 unsigned long long presentation,
200 TimestampFormat::Enum format);
201
202 private:
203 Timestamp (long long totalSeconds, int subseconds);
204
205 friend struct HandlerCore::Common::TimeHelper;
206 TimeSpan sinceEpoch_;
207};
208
209inline
211 long long totalSeconds, int subseconds)
212 : sinceEpoch_ (totalSeconds, subseconds)
213
214{
215}
216
217inline
218unsigned int
220{
221 return sinceEpoch_.milliseconds();
222}
223
224inline
225unsigned int
227{
228 return sinceEpoch_.microseconds();
229}
230
231inline
232unsigned int
234{
235 return sinceEpoch_.nanoseconds();
236}
237
238inline
239const TimeSpan&
241{
242 return sinceEpoch_;
243}
244
245inline
246std::string
248 TimestampFormat::Enum format) const
249{
250 std::string str;
251
252 toString (str, format);
253
254 return str;
255}
256
257inline
260 const Timestamp& left,
261 const Timestamp& right)
262{
263 TimeSpan res (left.sinceEpoch() );
264 return res -= right.sinceEpoch();
265}
266
#define ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN
Definition Bootstrap.h:27
#define ONIXS_ESPEED_ITCH_NAMESPACE_END
Definition Bootstrap.h:31
bool operator<(const StrRef &left, const StrRef &right)
Establishes order over string refs.
Definition String.h:414
bool operator==(const StrRef &left, const StrRef &right)
Compares StrRef instance with another one.
Definition String.h:310
bool operator!=(const StrRef &left, const StrRef &right)
Compares with another instance.
Definition String.h:324
TimeSpan operator-(const Timestamp &left, const Timestamp &right)
Definition Timestamp.h:259
UInt64 RawTimestamp
Definition Timestamp.h:86
Represents timestamp without time-zone information.
Definition Timestamp.h:90
static Timestamp parse(const std::string &, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec)
static Timestamp now()
Timestamp()
Initializes as Jan 1, 0001, 00:00:00.
unsigned int hour() const
unsigned int millisecond() const
Definition Timestamp.h:219
const TimeSpan & sinceEpoch() const
Time span since Jan 1, 0001, 00:00:00.
Definition Timestamp.h:240
void date(YearMonthDay &) const
Returns date part of timestamp.
void toString(std::string &str, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec) const
unsigned int day() const
static Timestamp parse(unsigned long long presentation, TimestampFormat::Enum format)
Parses timestamp from its numeric presentation.
static Timestamp epoch()
Epoch.
static Timestamp utcNow()
Timestamp(unsigned int year, Month::Enum month, unsigned int day, unsigned int hour=0, unsigned int minute=0, unsigned int second=0, unsigned int nanosecond=0)
Initializes date-time from all details.
unsigned year() const
Year component of timestamp.
std::string toString(TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec) const
Definition Timestamp.h:247
unsigned int nanosecond() const
Definition Timestamp.h:233
Timestamp(RawTimestamp ts)
unsigned int minute() const
unsigned int microsecond() const
Definition Timestamp.h:226
Month::Enum month() const
Month component of timestamp.
unsigned int second() const
Defines all the months in the year.
Definition Timestamp.h:32
Enum
Defines all the months in the year.
Definition Timestamp.h:35
@ December
Definition Timestamp.h:48
@ Undefined
Definition Timestamp.h:36
@ August
Definition Timestamp.h:44
@ January
Definition Timestamp.h:37
@ July
Definition Timestamp.h:43
@ May
Definition Timestamp.h:41
@ March
Definition Timestamp.h:39
@ February
Definition Timestamp.h:38
@ April
Definition Timestamp.h:40
@ November
Definition Timestamp.h:47
@ October
Definition Timestamp.h:46
@ June
Definition Timestamp.h:42
@ September
Definition Timestamp.h:45
Collection of timestamp formats supported.
Definition Timestamp.h:67
@ YYYYMMDDHHMMSS
Indicates timestamp in "YYYYMMDD-HH:MM:SS" format.
Definition Timestamp.h:74
@ YYYYMMDDHHMMSSMsec
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sss" format.
Definition Timestamp.h:77
@ YYYYMMDD
Indicates timestamp in "YYYYMMDD" format.
Definition Timestamp.h:71
@ YYYYMMDDHHMMSSNsec
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition Timestamp.h:80
Year, month, day fields.
Definition Timestamp.h:54
unsigned year
Year.
Definition Timestamp.h:56
unsigned day
Day.
Definition Timestamp.h:62
Month::Enum month
Month.
Definition Timestamp.h:59