API Guides > ConceptRT 3.x
RTTimeSpan.h
1 // //
3 // <copyright company="Objectis"> //
4 // //
5 // Copyright (c) 2013, All Right Reserved, http://www.objectis.ch/ //
6 // //
7 // This source is subject to the Objectis Permissive License. //
8 // Please see the License contract for more information. //
9 // All other rights reserved. //
10 // //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY //
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE //
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A //
14 // PARTICULAR PURPOSE. //
15 // //
16 // </copyright> //
17 // //
19 
20 #ifndef __RT_TIMESPAN_H_
21 #define __RT_TIMESPAN_H_
22 
23 #include "RTString.h"
24 
25 namespace ConceptRT
26 {
31  {
32  RT_DYNAMIC_CAST_1(TimeSpan, IStringConvertible)
33  public:
34 
36  TimeSpan();
37 
40  explicit TimeSpan(TimeStamp timeStamp);
41 
44  explicit TimeSpan(const String& text);
45 
53  TimeSpan(Int32 day, Int32 hour, Int32 minute, Int32 second,
54  Int32 millisecond = 0, Int32 microsecond = 0);
55 
63  void SetTimeSpan(Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond = 0, Int32 microsecond = 0);
64 
72  void GetTimeSpan(Int32 & day, Int32 & hour, Int32 & minute, Int32 & second,
73  Int32 & millisecond, Int32 & microsecond) const;
74 
77  Int32 GetDay() const;
78 
81  Int32 GetHour() const;
82 
85  Int32 GetMinute() const;
86 
91  Int32 GetSecond() const;
92 
97  Int32 GetMillisecond() const;
98 
103  Int32 GetMicrosecond() const;
104 
105  // IStringConvertible override
109  void ConvertFrom(PCChar8 text) override;
110  void ConvertTo(BaseStaticString& text) const override;
111 
114  TimeStamp ToTimeStamp() const;
115 
119  TimeSpan & operator+=(const TimeSpan & right);
120 
124  TimeSpan & operator-=(const TimeSpan & right);
125 
130  Int32 ToSeconds() const;
131 
136  Int32 ToMilliseconds() const;
137 
142  Int32 ToMicroseconds() const;
143 
144  private:
145  TimeStamp _timeStamp;
146  TimeStamp Encode(Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond, Int32 microsecond) const;
147  void Decode(TimeStamp timeSpan, Int32 & day, Int32 & hour, Int32 & minute, Int32 & second,
148  Int32 & millisecond, Int32 & microsecond) const;
149  };
150 
155 
160 
165 
170 
175 
180 
185 
190 
195  TimeSpan CONCEPTRT_API operator+(const TimeSpan & left, const TimeSpan & right);
196 
201  TimeSpan CONCEPTRT_API operator-(const TimeSpan & left, const TimeSpan & right);
202 
207  bool CONCEPTRT_API operator<(const TimeSpan & left, const TimeSpan & right);
208 
213  bool CONCEPTRT_API operator>(const TimeSpan & left, const TimeSpan & right);
214 
219  bool CONCEPTRT_API operator==(const TimeSpan & left, const TimeSpan & right);
220 
225  bool CONCEPTRT_API operator<=(const TimeSpan & left, const TimeSpan & right);
226 
231  bool CONCEPTRT_API operator>=(const TimeSpan & left, const TimeSpan & right);
232 
237  bool CONCEPTRT_API operator!=(const TimeSpan & left, const TimeSpan & right);
238 
240  extern const TimeSpan CONCEPTRT_API TimeInfinite;
242  extern const TimeSpan CONCEPTRT_API TimeZero;
243 
246 
248  enum DayPerYearConst { DayPerYear = 365 };
265 }
266 #endif
DayPerYearConst
DayPerYearConst
Definition: RTTimeSpan.h:248
MicrosecondPerMillisecondConst
MicrosecondPerMillisecondConst
Definition: RTTimeSpan.h:262
TimeSpan Milliseconds(Int32 value)
TimeSpan from milliseconds.
TimeSpan operator-(const Time &left, const Time &right)
Subtraction operator.
bool operator!=(const Nullable< valueType > &left, const Nullable< valueType > right)
Not equal operator for nullables
Definition: RTContainers.h:1906
MonthPerYearConst
MonthPerYearConst
Definition: RTTimeSpan.h:250
bool operator<=(const Time &left, const Time &right)
Less-than-or-equal comparison operator.
Time operator+(const Time &left, const TimeSpan &timeSpan)
Addition operator.
Definition: RTTimeSpan.h:252
bool operator>=(const Time &left, const Time &right)
Greater-than-or-equal comparison operator.
Definition: RTTimeSpan.h:258
MillisecondPerSecondConst
MillisecondPerSecondConst
Definition: RTTimeSpan.h:260
TimeSpan Seconds(Int32 value)
TimeSpan from seconds.
Definition: RTTimeSpan.h:260
TickPerMicrosecondConst
TickPerMicrosecondConst
Definition: RTTimeSpan.h:264
#define CONCEPTRT_API
ConceptRT export symbols for dynamic library exportation and importation.
Definition: RTDefinesUtils.h:70
Int64 TimeStamp
Type for 64 bits timestamp, in 100 ns unit.
Definition: RTTypesConcept.h:135
Definition: RTTimeSpan.h:262
const TimeSpan TimeInfinite
The time infinite
TimeSpan Weeks(Int32 value)
TimeSpan from weeks.
DayPerWeekConst
DayPerWeekConst
Definition: RTTimeSpan.h:252
MinutePerHourConst
MinutePerHourConst
Definition: RTTimeSpan.h:256
Definition: RTTimeSpan.h:254
HourPerDayConst
HourPerDayConst
Definition: RTTimeSpan.h:254
TimeSpan Microseconds(Int32 value)
TimeSpan from microseconds.
bool operator<(const Time &left, const Time &right)
Less-than comparison operator.
long Int32
Type for 32 bits signed integers.
Definition: RTTypesConcept.h:87
Time unit. Resolution is 100 ns.
Definition: RTTimeSpan.h:30
Definition: RTTimeSpan.h:264
Definition: RTTimeSpan.h:248
SecondPerMinuteConst
SecondPerMinuteConst
Definition: RTTimeSpan.h:258
TimeSpan Days(Int32 value)
TimeSpan from days.
Definition: RTTimeSpan.h:256
TimeSpan Hours(Int32 value)
TimeSpan from hours.
const Char8 * PCChar8
Type for pointers on 8 bits const characters.
Definition: RTTypesConcept.h:114
bool operator>(const Time &left, const Time &right)
Greater-than comparison operator.
const TimeSpan TimeZero
The time zero
bool operator==(const BaseSafeArray< ElementType > &left, const BaseSafeArray< ElementType > &right)
Equality operator.
Definition: RTContainers.h:357
Interface for values that give the service of being string convertible.
Definition: RTString.h:969
const PCChar8 TextTimeSpanInfinite
The text that defines a time span infinite
Library conceptRT namespace. Don't forget to use.
TimeSpan Minutes(Int32 value)
TimeSpan from minutes.
Basic static string class that handle fundamental string's functionalities.
Definition: RTString.h:215
Definition: RTTimeSpan.h:250