OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers 18.2.0
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
26
27
28namespace OnixS
29{
30 namespace Eurex
31 {
32 namespace MarketData
33 {
55
57 struct ONIXS_EUREX_EMDI_API YearMonthDay
58 {
59 unsigned year;
61 unsigned day;
62 };
63
65 struct ONIXS_EUREX_EMDI_API TimestampFormat
66 {
81 };
82
84 typedef Int64 Ticks;
85
87 class ONIXS_EUREX_EMDI_API Timestamp
88 {
89 public:
92
95 unsigned int year, Month::Enum month, unsigned int day,
96 unsigned int hour = 0, unsigned int minute = 0, unsigned int second = 0,
97 unsigned int nanosecond = 0);
98
100 explicit
102
104 unsigned year() const;
105
108
111 unsigned int day() const;
112
114 void date (YearMonthDay&) const;
115
118 unsigned int hour() const;
119
122 unsigned int minute() const;
123
126 unsigned int second() const;
127
130 unsigned int millisecond() const;
131
134 unsigned int microsecond() const;
135
138 unsigned int nanosecond() const;
139
141 const TimeSpan& sinceEpoch() const;
142
144 static Timestamp epoch();
145
147 bool operator == (const Timestamp&) const;
148
150 bool operator != (const Timestamp&) const;
151
153 bool operator < (const Timestamp&) const;
154
157 std::string
158 toString (
161
164 void
166 std::string& str,
169
175
180 static Timestamp now();
181
184 static
187 const std::string&,
190
193 static
196 unsigned long long presentation,
198
199 private:
200 Timestamp (long long totalSeconds, int subseconds);
201
202 friend class TimeManager;
203 TimeSpan sinceEpoch_;
204 };
205
206 inline
208 long long totalSeconds, int subseconds)
209 : sinceEpoch_(totalSeconds, subseconds)
210
211 {
212 }
213
214 inline
215 unsigned int
217 {
218 return sinceEpoch_.milliseconds();
219 }
220
221 inline
222 unsigned int
224 {
225 return sinceEpoch_.microseconds();
226 }
227
228 inline
229 unsigned int
231 {
232 return sinceEpoch_.nanoseconds();
233 }
234
235 inline
236 const TimeSpan&
238 {
239 return sinceEpoch_;
240 }
241
242 inline
243 std::string
245 TimestampFormat::Enum format) const
246 {
247 std::string str;
248
249 toString (str, format);
250
251 return str;
252 }
253
254 inline
257 const Timestamp& left,
258 const Timestamp& right)
259 {
260 TimeSpan res(left.sinceEpoch());
261 return res -= right.sinceEpoch();
262 }
263
264 inline
265 std::ostream&
267 std::ostream& os
268 , const Timestamp& timestamp)
269 {
270 return os << timestamp.toString();
271 }
272 }
273 }
274}
Represents timestamp without time-zone information.
Definition Timestamp.h:88
static Timestamp parse(const std::string &, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec)
Timestamp()
Initializes as Jan 1, 0001, 00:00:00.
unsigned int millisecond() const
Definition Timestamp.h:216
const TimeSpan & sinceEpoch() const
Time span since Jan 1, 0001, 00:00:00.
Definition Timestamp.h:237
static Timestamp parse(unsigned long long presentation, TimestampFormat::Enum format=TimestampFormat::YYYYMMDD)
void date(YearMonthDay &) const
Returns date part of timestamp.
void toString(std::string &str, TimestampFormat::Enum=TimestampFormat::YYYYMMDDHHMMSSNsec) const
static Timestamp epoch()
Epoch.
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:244
unsigned int nanosecond() const
Definition Timestamp.h:230
Timestamp(Ticks ticks)
Initializes date-time from raw presentantion.
unsigned int microsecond() const
Definition Timestamp.h:223
Month::Enum month() const
Month component of timestamp.
std::ostream & operator<<(std::ostream &os, const Message &message)
TimeSpan operator-(const Timestamp &left, const Timestamp &right)
Definition Timestamp.h:256
Int64 Ticks
Integral type presenting internal ticks.
Definition Timestamp.h:84
Defines all the months in the year.
Definition Timestamp.h:36
Enum
Defines all the months in the year.
Definition Timestamp.h:39
Collection of timestamp formats supported.
Definition Timestamp.h:66
@ YYYYMMDDHHMMSS
Indicates timestamp in "YYYYMMDD-HH:MM:SS" format.
Definition Timestamp.h:73
@ YYYYMMDDHHMMSSMsec
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sss" format.
Definition Timestamp.h:76
@ YYYYMMDD
Indicates timestamp in "YYYYMMDD" format.
Definition Timestamp.h:70
@ YYYYMMDDHHMMSSNsec
Indicates timestamp in "YYYYMMDD-HH:MM:SS.sssssssss" format.
Definition Timestamp.h:79
Year, month, day fields.
Definition Timestamp.h:58