CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
date_time.h
1
3#pragma once
4
5#include <system/date_time_kind.h>
6#include <system/day_of_week.h>
7#include <system/timespan.h>
8#include <system/boxable_traits.h>
9#include <system/globalization/date_time_styles.h>
10#include <functional>
11#include <memory>
12
13namespace System {
14
15namespace Globalization {
16 class Calendar;
17 class CultureInfo;
18 class DateTimeFormatInfo;
19}
20
49class ASPOSECPP_SHARED_CLASS DateTime final
50{
51public:
52 // Number of 100ns ticks per time unit
54 static constexpr int64_t TicksPerMicrosecond = 10;
56 static constexpr int64_t TicksPerMillisecond = 10000;
58 static constexpr int64_t TicksPerSecond = TicksPerMillisecond * 1000;
60 static constexpr int64_t TicksPerMinute = TicksPerSecond * 60;
62 static constexpr int64_t TicksPerHour = TicksPerMinute * 60;
64 static constexpr int64_t TicksPerDay = TicksPerHour * 24;
65
67 static constexpr int64_t MinTicks = 0;
69 static constexpr int64_t MaxTicks = 3652059 * TicksPerDay - 1;
70
72 static ASPOSECPP_SHARED_API const DateTime MinValue;
73
75 static ASPOSECPP_SHARED_API const DateTime MaxValue;
76
78 static ASPOSECPP_SHARED_API const DateTime UnixEpoch;
79
81 constexpr DateTime() : m_data(0) {}
82
87 ASPOSECPP_SHARED_API DateTime(int year, int month, int day);
88
94 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, const SharedPtr<Globalization::Calendar>& calendar);
95
103 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, int hour, int minute, int second);
104
113 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, int hour, int minute, int second, DateTimeKind kind);
114
123 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, int hour, int minute, int second, const SharedPtr<Globalization::Calendar>& calendar);
124
134 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind = DateTimeKind::Unspecified);
135
146 ASPOSECPP_SHARED_API DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, const SharedPtr<Globalization::Calendar>& calendar, DateTimeKind kind = DateTimeKind::Unspecified);
147
151 ASPOSECPP_SHARED_API DateTime(int64_t ticks, DateTimeKind kind = DateTimeKind::Unspecified);
152
157 DateTime(int64_t ticks, DateTimeKind kind, bool is_ambiguous_local_dst);
158
161 DateTime(const DateTime& dt) = default;
162
166 DateTime& operator=(const DateTime& dt) = default;
167
169 constexpr DateTime get_Date() const
170 {
171 const int64_t ticks = get_Ticks();
172 return DateTime(static_cast<uint64_t>(ticks - (ticks % TicksPerDay)) | Flags(), InternalConstructor);
173 }
174
176 constexpr DayOfWeek get_DayOfWeek() const
177 {
178 return static_cast<DayOfWeek>((get_Ticks() / TicksPerDay + 1) % 7);
179 }
180
182 constexpr DateTimeKind get_Kind() const
183 {
184 return static_cast<DateTimeKind>(std::min(2, static_cast<int>(m_data >> 62)));
185 }
186
188 constexpr TimeSpan get_TimeOfDay() const
189 {
190 return TimeSpan(get_Ticks() % TicksPerDay);
191 }
192
194 ASPOSECPP_SHARED_API int get_DayOfYear() const;
195
197 ASPOSECPP_SHARED_API int get_Year() const;
198
200 ASPOSECPP_SHARED_API int get_Month() const;
201
203 ASPOSECPP_SHARED_API int get_Day() const;
204
206 void GetDateComponents(int& year, int& month, int& day) const;
207
209 constexpr int get_Hour() const
210 {
211 return static_cast<int>((get_Ticks() / TicksPerHour) % 24);
212 }
213
215 constexpr int get_Minute() const
216 {
217 return static_cast<int>((get_Ticks() / TicksPerMinute) % 60);
218 }
219
221 constexpr int get_Second() const
222 {
223 return static_cast<int>((get_Ticks() / TicksPerSecond) % 60);
224 }
225
227 constexpr int get_Millisecond() const
228 {
229 return static_cast<int>((get_Ticks() / TicksPerMillisecond) % 1000);
230 }
231
233 constexpr int64_t get_Ticks() const
234 {
235 return static_cast<int64_t>(m_data & TicksMask);
236 }
237
239 static ASPOSECPP_SHARED_API DateTime get_Now();
240
242 static ASPOSECPP_SHARED_API DateTime get_UtcNow();
243
245 static ASPOSECPP_SHARED_API DateTime get_Today();
246
250 ASPOSECPP_SHARED_API DateTime Add(TimeSpan value) const;
251
255 ASPOSECPP_SHARED_API DateTime AddYears(int value) const;
256
260 ASPOSECPP_SHARED_API DateTime AddMonths(int value) const;
261
265 ASPOSECPP_SHARED_API DateTime AddDays(double value) const;
266
270 ASPOSECPP_SHARED_API DateTime AddHours(double value) const;
271
275 ASPOSECPP_SHARED_API DateTime AddMinutes(double value) const;
276
280 ASPOSECPP_SHARED_API DateTime AddSeconds(double value) const;
281
285 ASPOSECPP_SHARED_API DateTime AddMilliseconds(double value) const;
286
290 ASPOSECPP_SHARED_API DateTime AddTicks(int64_t value) const;
291
295 ASPOSECPP_SHARED_API DateTime Subtract(TimeSpan duration) const;
296
300 constexpr TimeSpan Subtract(DateTime value) const
301 {
302 return TimeSpan(get_Ticks() - value.get_Ticks());
303 }
304
306 ASPOSECPP_SHARED_API DateTime ToLocalTime() const;
307
309 ASPOSECPP_SHARED_API DateTime ToUniversalTime() const;
310
312 time_t ToUnixTime() const;
313
315 ASPOSECPP_SHARED_API int64_t ToFileTime() const;
316
319 ASPOSECPP_SHARED_API int64_t ToFileTimeUtc() const;
320
323 ASPOSECPP_SHARED_API int64_t ToBinary() const;
324
326 ASPOSECPP_SHARED_API double ToOADate() const;
327
331 static ASPOSECPP_SHARED_API DateTime FromBinary(int64_t value);
332
336 static ASPOSECPP_SHARED_API DateTime FromFileTimeUtc(int64_t file_time);
337
341 static ASPOSECPP_SHARED_API DateTime FromOADate(double date);
342
346 static DateTime FromUnixTime(time_t value);
347
351 static ASPOSECPP_SHARED_API DateTime FromFileTime(int64_t value);
352
357 static ASPOSECPP_SHARED_API int DaysInMonth(int year, int month);
358
362 static ASPOSECPP_SHARED_API bool IsLeapYear(int year);
363
366 ASPOSECPP_SHARED_API bool IsDaylightSavingTime() const;
367
374 {
375 return DateTime(value.get_Ticks(), kind);
376 }
377
382 static constexpr int Compare(DateTime t1, DateTime t2)
383 {
384 return (t1 < t2 ? -1 : (t2 < t1 ? 1 : 0));
385 }
386
390 constexpr int CompareTo(DateTime value) const
391 {
392 return Compare(*this, value);
393 }
394
399 static constexpr bool Equals(DateTime t1, DateTime t2)
400 {
401 return t1.get_Ticks() == t2.get_Ticks();
402 }
403
407 constexpr bool Equals(DateTime other) const
408 {
409 return get_Ticks() == other.get_Ticks();
410 }
411
413 ASPOSECPP_SHARED_API int GetHashCode() const;
414
417 ASPOSECPP_SHARED_API String ToString() const;
418
422 ASPOSECPP_SHARED_API String ToString(const String& format) const;
423
427 ASPOSECPP_SHARED_API String ToString(const SharedPtr<IFormatProvider>& provider) const;
428 // Optimized function overloads
429 ASPOSECPP_SHARED_API String ToString(const SharedPtr<Globalization::CultureInfo>& culture) const;
430 ASPOSECPP_SHARED_API String ToString(const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi) const;
431 String ToString(std::nullptr_t) const { return ToString(); }
432
437 ASPOSECPP_SHARED_API String ToString(const String& format, const SharedPtr<IFormatProvider>& provider) const;
438 // Optimized function overloads
439 ASPOSECPP_SHARED_API String ToString(const String& format, const SharedPtr<Globalization::CultureInfo>& culture) const;
440 ASPOSECPP_SHARED_API String ToString(const String& format, const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi) const;
441 String ToString(const String& format, std::nullptr_t) const { return ToString(format); }
442
444 ASPOSECPP_SHARED_API String ToShortDateString() const;
445
447 ASPOSECPP_SHARED_API String ToLongDateString() const;
448
450 ASPOSECPP_SHARED_API String ToShortTimeString() const;
451
453 ASPOSECPP_SHARED_API String ToLongTimeString() const;
454
457 ASPOSECPP_SHARED_API ArrayPtr<String> GetDateTimeFormats() const;
461 ASPOSECPP_SHARED_API ArrayPtr<String> GetDateTimeFormats(char_t format) const;
465 ASPOSECPP_SHARED_API ArrayPtr<String> GetDateTimeFormats(const SharedPtr<IFormatProvider>& provider) const;
470 ASPOSECPP_SHARED_API ArrayPtr<String> GetDateTimeFormats(char_t format, const SharedPtr<IFormatProvider>& provider) const;
471
475 static ASPOSECPP_SHARED_API DateTime Parse(const String& s);
476
483 // Optimized function overloads
486 static ASPOSECPP_SHARED_API DateTime Parse(const String& s, std::nullptr_t, Globalization::DateTimeStyles styles = Globalization::DateTimeStyles::None);
487
496 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const String& format, const SharedPtr<IFormatProvider>& provider, Globalization::DateTimeStyles styles = Globalization::DateTimeStyles::None);
497 // Optimized function overloads
500 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const String& format, std::nullptr_t, Globalization::DateTimeStyles styles = Globalization::DateTimeStyles::None);
501
510 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<IFormatProvider>& provider, Globalization::DateTimeStyles styles);
511 // Optimized function overloads
512 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<Globalization::CultureInfo>& culture, Globalization::DateTimeStyles styles);
513 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi, Globalization::DateTimeStyles styles);
514 static ASPOSECPP_SHARED_API DateTime ParseExact(const String& s, const ArrayPtr<String>& formats, std::nullptr_t, Globalization::DateTimeStyles styles);
515
520 static ASPOSECPP_SHARED_API bool TryParse(const String& s, DateTime& result);
521
529 static ASPOSECPP_SHARED_API bool TryParse(const String& s, const SharedPtr<IFormatProvider>& provider, Globalization::DateTimeStyles styles, DateTime& result);
530 // Optimized function overloads
531 static ASPOSECPP_SHARED_API bool TryParse(const String& s, const SharedPtr<Globalization::CultureInfo>& culture, Globalization::DateTimeStyles styles, DateTime& result);
532 static ASPOSECPP_SHARED_API bool TryParse(const String& s, const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi, Globalization::DateTimeStyles styles, DateTime& result);
533 static ASPOSECPP_SHARED_API bool TryParse(const String& s, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime& result);
534
544 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const String& format, const SharedPtr<IFormatProvider>& provider, Globalization::DateTimeStyles styles, DateTime& result);
545 // Optimized function overloads
546 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const String& format, const SharedPtr<Globalization::CultureInfo>& culture, Globalization::DateTimeStyles styles, DateTime& result);
547 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const String& format, const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi, Globalization::DateTimeStyles styles, DateTime& result);
548 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const String& format, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime& result);
549
559 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<IFormatProvider>& provider, Globalization::DateTimeStyles styles, DateTime& result);
560 // Optimized function overloads
561 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<Globalization::CultureInfo>& culture, Globalization::DateTimeStyles styles, DateTime& result);
562 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const ArrayPtr<String>& formats, const SharedPtr<Globalization::DateTimeFormatInfo>& dtfi, Globalization::DateTimeStyles styles, DateTime& result);
563 static ASPOSECPP_SHARED_API bool TryParseExact(const String& s, const ArrayPtr<String>& formats, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime& result);
564
568 constexpr bool operator==(DateTime other) const
569 {
570 return get_Ticks() == other.get_Ticks();
571 }
572
576 constexpr bool operator!=(DateTime other) const
577 {
578 return get_Ticks() != other.get_Ticks();
579 }
580
584 constexpr bool operator<(DateTime other) const
585 {
586 return get_Ticks() < other.get_Ticks();
587 }
588
592 constexpr bool operator<=(DateTime other) const
593 {
594 return get_Ticks() <= other.get_Ticks();
595 }
596
600 constexpr bool operator>(DateTime other) const
601 {
602 return get_Ticks() > other.get_Ticks();
603 }
604
608 constexpr bool operator>=(DateTime other) const
609 {
610 return get_Ticks() >= other.get_Ticks();
611 }
612
617 {
618 return Add(value);
619 }
620
625 {
626 return Subtract(value);
627 }
628
633 {
634 return *this = Add(value);
635 }
636
641 {
642 return *this = Subtract(value);
643 }
644
648 constexpr TimeSpan operator-(DateTime value) const
649 {
650 return Subtract(value);
651 }
652
654 static const TypeInfo& Type()
655 {
656 return *static_holder<ThisTypeInfo>();
657 }
658
659 constexpr bool IsNull() const { return false; }
660 constexpr bool operator==(std::nullptr_t) const { return false; }
661 constexpr bool operator!=(std::nullptr_t) const { return true; }
662 constexpr bool operator<(std::nullptr_t) const { return false; }
663 constexpr bool operator<=(std::nullptr_t) const { return false; }
664 constexpr bool operator>(std::nullptr_t) const { return false; }
665 constexpr bool operator>=(std::nullptr_t) const { return false; }
666
667private:
671 uint64_t m_data;
672
673 static constexpr uint64_t TicksMask = 0x3FFFFFFFFFFFFFFF;
674 static constexpr uint64_t FlagsMask = 0xC000000000000000;
675
677 constexpr uint64_t Flags() const { return m_data & FlagsMask; }
679 struct InternalConstructorTag {};
680 static constexpr InternalConstructorTag InternalConstructor{};
682 constexpr DateTime(uint64_t data, InternalConstructorTag) : m_data(data) {}
683
685 struct ThisTypeInfo : TypeInfoPtr
686 {
688 ThisTypeInfo()
689 : TypeInfoPtr(u"System::DateTime")
690 {}
691 };
692
693#if defined(_DEBUG) && defined(_MSC_VER)
694 struct NatvisHelpers
695 {
696 static constexpr unsigned DaysTo1901 = 693960;
697 static constexpr unsigned DaysTo2100 = 766644;
698 static constexpr unsigned DaysTo10000 = 3652058;
699 static constexpr unsigned DaysPer4Years = 1461;
700
701 struct Date { uint64_t ticks : 62; };
702 struct Days { uint64_t ticks:62; };
703 struct HoursMinutesSeconds { uint64_t ticks:62; };
704 struct Fraction { uint64_t ticks:62; };
705 struct TimeOfDay { uint64_t data; };
706 };
707#endif
708};
709
710constexpr bool operator==(std::nullptr_t, DateTime) { return false; }
711constexpr bool operator!=(std::nullptr_t, DateTime) { return true; }
712constexpr bool operator<(std::nullptr_t, DateTime) { return false; }
713constexpr bool operator<=(std::nullptr_t, DateTime) { return false; }
714constexpr bool operator>(std::nullptr_t, DateTime) { return false; }
715constexpr bool operator>=(std::nullptr_t, DateTime) { return false; }
716
719template<> struct IsBoxable<DateTime> : std::true_type {};
721
723ASPOSECPP_SHARED_API void PrintTo(DateTime value, std::ostream* stream);
724
729inline std::ostream& operator<<(std::ostream& stream, DateTime date_time)
730{
731 stream << date_time.ToString();
732 return stream;
733}
734
739inline std::wostream& operator<<(std::wostream& stream, DateTime date_time)
740{
741 stream << date_time.ToString();
742 return stream;
743}
744
745} // namespace System
746
747namespace std {
749 template <>
750 class hash<System::DateTime>
751 {
752 public:
754 using argument_type = System::DateTime;
756 using result_type = std::size_t;
760 result_type operator()(const argument_type& value) const
761 {
762 return static_cast<result_type>(value.GetHashCode());
763 }
764 };
765}
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
String ToString(const SharedPtr< Globalization::CultureInfo > &culture) const
String ToString(const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi) const
constexpr bool operator==(DateTime other) const
Determines if the current object and the specified DateTime object represent the same date and time v...
Definition: date_time.h:568
constexpr bool IsNull() const
Definition: date_time.h:659
static bool TryParse(const String &s, DateTime &result)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
constexpr bool operator>(DateTime other) const
Determines if the current object represents the date and time value that is later than the value repr...
Definition: date_time.h:600
String ToString(std::nullptr_t) const
Definition: date_time.h:431
String ToShortDateString() const
Returns a string that contains the short date string representation of the current object.
DateTime AddTicks(int64_t value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
static DateTime ParseExact(const String &s, const String &format, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
static const DateTime MaxValue
An instance of DateTime class that represents the maximal possible date and time value.
Definition: date_time.h:75
static bool TryParseExact(const String &s, const String &format, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles, DateTime &result)
String ToString(const String &format, const SharedPtr< IFormatProvider > &provider) const
Returns a string representation of the date and time value represented by the current object using th...
String ToString(const String &format, const SharedPtr< Globalization::CultureInfo > &culture) const
int get_DayOfYear() const
Returns the ordinal number of the day in the year represented by the current object.
DateTime AddMinutes(double value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
int get_Day() const
Returns the ordinal number of the day in the month represented by the current object.
constexpr int64_t get_Ticks() const
Returns a number of 100-nanosecond intervals passed since 0:00:00 UTC, January 1, 0001,...
Definition: date_time.h:233
int64_t ToBinary() const
Serializes the current object.
double ToOADate() const
Returns the date and time value represented by the current object as OLE Automation Date.
static bool TryParseExact(const String &s, const String &format, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles, DateTime &result)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind=DateTimeKind::Unspecified)
Constructs an instance that represents a date and time value specified as a particular year,...
static constexpr int Compare(DateTime t1, DateTime t2)
Compares two values represented by the specified instances of DateTime class and returns the value in...
Definition: date_time.h:382
constexpr DateTime()
Constructs an instance that represents the smallest possible date and time value equal to MinValue.
Definition: date_time.h:81
constexpr int get_Hour() const
Returns the hour component of the date and time value represented by the current object.
Definition: date_time.h:209
ArrayPtr< String > GetDateTimeFormats(const SharedPtr< IFormatProvider > &provider) const
Returns array of strings where each element is the string representation of the current object format...
String ToString(const String &format, std::nullptr_t) const
Definition: date_time.h:441
constexpr int get_Second() const
Returns the second component of the date and time value represented by the current object.
Definition: date_time.h:221
static DateTime ParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles)
DateTime(int year, int month, int day)
Constructs an instance that represents a date and time value specified as a particular year,...
static DateTime Parse(const String &s, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
constexpr bool operator<(DateTime other) const
Determines if the current object represents the date and time value that is earlier than the value re...
Definition: date_time.h:584
static DateTime Parse(const String &s, std::nullptr_t, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
static DateTime Parse(const String &s)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
String ToLongDateString() const
Returns a string that contains the long date string representation of the current object.
DateTime AddMonths(int value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
static DateTime ParseExact(const String &s, const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
DateTime & operator-=(TimeSpan value)
Sets the current object to the date and time value that is the result of subtraction of the specified...
Definition: date_time.h:640
constexpr TimeSpan operator-(DateTime value) const
Returns an instance of TimeSpan class that represents the time interval between the date and time val...
Definition: date_time.h:648
constexpr int get_Minute() const
Returns the minute component of the date and time value represented by the current object.
Definition: date_time.h:215
DateTime operator-(TimeSpan value) const
Returns a new instance of the DateTime class representing the date and time value which is the result...
Definition: date_time.h:624
static bool TryParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles, DateTime &result)
bool IsDaylightSavingTime() const
Determines if the date and time value represented by the current object falls in the range of dayligh...
static bool TryParse(const String &s, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles, DateTime &result)
DateTime ToLocalTime() const
Returns a new instance of DateTime class that represents the date and time value represented by the c...
DateTime(int64_t ticks, DateTimeKind kind, bool is_ambiguous_local_dst)
Construct an instance that represents a date and time value specified as a number of ticks....
constexpr bool operator>=(DateTime other) const
Determines if the current object represents the date and time value that is later than or the same as...
Definition: date_time.h:608
static DateTime FromOADate(double date)
Returns an instance of DateTime class representing the date and time value equivalent to the specifie...
String ToLongTimeString() const
Returns a string that contains the long time string representation of the current object.
constexpr TimeSpan get_TimeOfDay() const
Returns the value that represents the time interval from the beginning of the day represented by the ...
Definition: date_time.h:188
String ToShortTimeString() const
Returns a string that contains the short time string representation of the current object.
ArrayPtr< String > GetDateTimeFormats(char_t format, const SharedPtr< IFormatProvider > &provider) const
Returns array of strings where each element is the string representation of the current object format...
DateTime AddMilliseconds(double value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
DateTime AddYears(int value) const
Returns a new instance of the DateTime class representing the date and time value equal to that repre...
static DateTime FromFileTimeUtc(int64_t file_time)
Converts the specified File time to an instance of DateTime class representing the same date and time...
constexpr bool operator>(std::nullptr_t) const
Definition: date_time.h:664
static DateTime Parse(const String &s, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
constexpr bool operator==(std::nullptr_t) const
Definition: date_time.h:660
DateTime(int64_t ticks, DateTimeKind kind=DateTimeKind::Unspecified)
Construct an instance that represents a date and time value specified as a number of ticks.
constexpr int get_Millisecond() const
Returns the millisecond component of the date and time value represented by the current object.
Definition: date_time.h:227
DateTime AddHours(double value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
static DateTime get_Today()
Returns an instance of DateTime class that represents the current date with each component of time po...
constexpr bool operator<(std::nullptr_t) const
Definition: date_time.h:662
DateTime(int year, int month, int day, const SharedPtr< Globalization::Calendar > &calendar)
Constructs an instance that represents a date and time value specified as a particular year,...
DateTime Add(TimeSpan value) const
Returns a new instance of DateTime class that represents a date and time value that results from addi...
static bool TryParseExact(const String &s, const ArrayPtr< String > &formats, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime &result)
constexpr int CompareTo(DateTime value) const
Compares two date and time values represented by the current object and the specified instance of Dat...
Definition: date_time.h:390
static DateTime get_UtcNow()
Returns an instance of DateTime class that represents the current time as UTC.
static DateTime ParseExact(const String &s, const String &format, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
static bool TryParse(const String &s, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles, DateTime &result)
void GetDateComponents(int &year, int &month, int &day) const
Gets date parts. FOR INTERNAL USE.
static bool TryParseExact(const String &s, const String &format, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime &result)
constexpr bool operator!=(std::nullptr_t) const
Definition: date_time.h:661
ArrayPtr< String > GetDateTimeFormats(char_t format) const
Returns array of strings where each element is the string representation of the current object format...
static const DateTime UnixEpoch
An instance of DateTime class that represents the Unix epoch start (1970.01.01 00:00:00).
Definition: date_time.h:78
static bool TryParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles, DateTime &result)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
DateTime & operator=(const DateTime &dt)=default
Assigns the value represented by the specified DateTime instance to the current object.
static DateTime get_Now()
Returns an instance of DateTime class that represents the current time as local time.
String ToString(const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi) const
static bool TryParse(const String &s, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles, DateTime &result)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
String ToString() const
Returns the string representation of the date and time value represented by the current object using ...
static DateTime ParseExact(const String &s, const String &format, std::nullptr_t, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
static bool IsLeapYear(int year)
Determines of the specified year is a leap year.
DateTime(int year, int month, int day, int hour, int minute, int second)
Constructs an instance that represents a date and time value specified as a particular year,...
DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, const SharedPtr< Globalization::Calendar > &calendar, DateTimeKind kind=DateTimeKind::Unspecified)
Constructs an instance that represents a date and time value specified as a particular year,...
static DateTime Parse(const String &s, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles=Globalization::DateTimeStyles::None)
static bool TryParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles, DateTime &result)
constexpr DayOfWeek get_DayOfWeek() const
Returns a value representing a day of week that is represented by the current object.
Definition: date_time.h:176
static const TypeInfo & Type()
Returns a TypeInfo object that contains information about this class.
Definition: date_time.h:654
static DateTime ParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< IFormatProvider > &provider, Globalization::DateTimeStyles styles)
Converts the specified string representation of a date and time value to the equivalent DateTime obje...
static DateTime FromUnixTime(time_t value)
Converts the specified Unix time value to an instance of DateTime class. FOR INTERNAL USE.
int64_t ToFileTime() const
Returns a value that represents the date and time value represented by the current object as File tim...
int get_Month() const
Returns the ordinal number of the month in the year represented by the current object.
constexpr bool operator<=(std::nullptr_t) const
Definition: date_time.h:663
static constexpr bool Equals(DateTime t1, DateTime t2)
Determines if the specified instances of DateTime class represent the same date and time value.
Definition: date_time.h:399
String ToString(const SharedPtr< IFormatProvider > &provider) const
Returns a string representation of the date and time value represented by the current object using th...
ArrayPtr< String > GetDateTimeFormats() const
Returns array of strings where each element is the string representation of the current object format...
String ToString(const String &format) const
Returns a string representation of the date and time value represented by the current object using th...
int get_Year() const
Returns the year represented by the current object.
constexpr bool operator<=(DateTime other) const
Determines if the current object represents the date and time value that is earlier than or the same ...
Definition: date_time.h:592
DateTime Subtract(TimeSpan duration) const
Returns a new instance of the DateTime class representing the date and time value which is the result...
DateTime(int year, int month, int day, int hour, int minute, int second, DateTimeKind kind)
Constructs an instance that represents a date and time value specified as a particular year,...
constexpr bool operator>=(std::nullptr_t) const
Definition: date_time.h:665
DateTime AddDays(double value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
DateTime AddSeconds(double value) const
Returns a new instance of the DateTime class representing the date and time value which is the sum of...
static bool TryParse(const String &s, std::nullptr_t, Globalization::DateTimeStyles styles, DateTime &result)
static DateTime SpecifyKind(DateTime value, DateTimeKind kind)
Constructs a new DateTime object that represents the same number of ticks as the specified DateTime o...
Definition: date_time.h:373
DateTime(int year, int month, int day, int hour, int minute, int second, const SharedPtr< Globalization::Calendar > &calendar)
Constructs an instance that represents a date and time value specified as a particular year,...
time_t ToUnixTime() const
Returns a value that represents the date and time value represented by the current object as Unix tim...
int64_t ToFileTimeUtc() const
Converts the date and time value represented by the current object to File time UTC.
DateTime(const DateTime &dt)=default
Copy-constructs an instance.
static DateTime ParseExact(const String &s, const ArrayPtr< String > &formats, const SharedPtr< Globalization::CultureInfo > &culture, Globalization::DateTimeStyles styles)
DateTime & operator+=(TimeSpan value)
Sets the current object to the date and time value that is the sum of the value represented by the cu...
Definition: date_time.h:632
constexpr TimeSpan Subtract(DateTime value) const
Returns an instance of TimeSpan class representing the time interval between the date and time values...
Definition: date_time.h:300
static bool TryParseExact(const String &s, const String &format, const SharedPtr< Globalization::DateTimeFormatInfo > &dtfi, Globalization::DateTimeStyles styles, DateTime &result)
static const DateTime MinValue
An instance of DateTime class that represents the minimal possible date and time value.
Definition: date_time.h:72
static DateTime ParseExact(const String &s, const ArrayPtr< String > &formats, std::nullptr_t, Globalization::DateTimeStyles styles)
constexpr DateTime get_Date() const
Returns a new instance of DateTime class that represents the date portion of the date and time repres...
Definition: date_time.h:169
constexpr bool operator!=(DateTime other) const
Determines if the current object and the specified DateTime object represent distinct date and time v...
Definition: date_time.h:576
static int DaysInMonth(int year, int month)
Returns the number of days in the specified month of the specified year.
DateTime operator+(TimeSpan value) const
Returns a new instance of DateTime class that represents the date and time value that is the sum of t...
Definition: date_time.h:616
DateTime ToUniversalTime() const
Returns a new instance of DateTime class that represents the date and time value represented by the c...
static DateTime FromBinary(int64_t value)
Deserializes the date time value from the specified unsigned 64-bit integer and sets the new instance...
int GetHashCode() const
Returns a hash code for the current object.
static DateTime FromFileTime(int64_t value)
Converts the specified File time to an instance of DateTime class representing the same date and time...
constexpr DateTimeKind get_Kind() const
Returns the value representing if the date and time represented by the current object is a local or U...
Definition: date_time.h:182
constexpr bool Equals(DateTime other) const
Determines if the specified instance of DateTime class represent the same date and time value as the ...
Definition: date_time.h:407
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a time interval. This type should be allocated on stack and passed to functions by value o...
Definition: timespan.h:59
Represents a particular type and provides information about it.
Definition: type_info.h:109
DateTimeStyles
Defines date and time formatting options. Bit flags.
Definition: date_time_styles.h:12
@ Date
The 'Date' header.
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
std::enable_if_t<!std::is_floating_point< TA >::value &&!std::is_floating_point< TB >::value, int > Compare(const TA &a, const TB &b)
Compares two values.
Definition: primitive_types.h:113
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:157
DateTimeKind
Enumeration values of which represent the kinds of date and time.
Definition: date_time_kind.h:10
@ Unspecified
Unspecified kind.
@ DateTime
A type representing a date and time value.
constexpr bool operator>(std::nullptr_t, DateTime)
Definition: date_time.h:714
DayOfWeek
Enumeration that represents a day of week.
Definition: day_of_week.h:11
std::ostream & operator<<(std::ostream &stream, DateTime date_time)
Insert data into the stream using UTF-8 encoding.
Definition: date_time.h:729
constexpr bool operator<(std::nullptr_t, DateTime)
Definition: date_time.h:712
constexpr bool operator<=(std::nullptr_t, DateTime)
Definition: date_time.h:713
constexpr bool operator>=(std::nullptr_t, DateTime)
Definition: date_time.h:715
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151