2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseDateTime.cpp
19 * @brief This file contains implementation of DateTime class
23 #include <FBaseDateTime.h>
24 #include <FBaseResult.h>
25 #include <FBaseSysLog.h>
26 #include <unique_ptr.h>
28 namespace Tizen { namespace Base
47 NUM_OF_SEC_IN_DAY = 86400,
48 NUM_OF_SEC_IN_HOUR = 3600,
49 NUM_OF_SEC_IN_MINUTE = 60,
50 NUM_OF_TICKS_IN_DAY = 86400000LL,
51 NUM_OF_TICKS_IN_HOUR = 3600000LL,
52 NUM_OF_TICKS_IN_MINUTE = 60000LL,
53 NUM_OF_TICKS_IN_SECOND = 1000LL
56 static const int TICKS_PER_MILLISECOND = 1;
57 static const long SEC_IN_A_DAY = (24L * 60L * 60L);
58 static const long long MINIMUM_VALUE_IN_SEC = 86400LL;
59 static const int DAYS_IN_LEAP_YEAR[] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
60 static const int DAYS[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
61 static const int INT_HALF_BIT = 16;
62 static const int LOW_16BIT = 0xFFFF;
63 static const long long TOTAL_MAX_TICKS = DateTime::GetMaxValue().GetTicks();
65 DateTime::DateTime(void)
66 : __pDateTimeImpl(null)
68 SetValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
71 DateTime::DateTime(const DateTime& value)
72 : __pDateTimeImpl(null)
77 DateTime::~DateTime(void)
82 DateTime::SetValue(const TimeSpan& value)
84 long long total = value.GetTicks();
85 SysTryReturn(NID_BASE, total >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
86 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
88 SysTryReturn(NID_BASE, total <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
89 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
91 return ConvertTicksToDate(total, &__dateTime);
95 DateTime::SetValue(const DateTime& value)
97 __dateTime.year = value.__dateTime.year;
98 __dateTime.month = value.__dateTime.month;
99 __dateTime.day = value.__dateTime.day;
100 __dateTime.hour = value.__dateTime.hour;
101 __dateTime.minute = value.__dateTime.minute;
102 __dateTime.second = value.__dateTime.second;
106 DateTime::SetValue(int year, int month, int day, int hour, int minute, int second)
108 SysTryReturn(NID_BASE,
109 ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
110 (month >= MIN_MONTH && month <= MAX_MONTH) &&
111 (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
112 (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
113 ((second & LOW_16BIT) >= MIN_SECOND && (second & LOW_16BIT) <= MAX_SECOND) &&
114 ((second >> INT_HALF_BIT) >= MIN_TICK && (second >> INT_HALF_BIT) <= MAX_TICK)),
115 E_OUT_OF_RANGE, E_OUT_OF_RANGE,
116 "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
117 GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second & LOW_16BIT, second >> INT_HALF_BIT);
120 result r = GetDaysInMonth(year, month, daysInMonth);
121 SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
122 SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
123 ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
125 __dateTime.year = year;
126 __dateTime.month = month;
127 __dateTime.day = day;
128 __dateTime.hour = hour;
129 __dateTime.minute = minute;
130 __dateTime.second = second;
135 DateTime::SetValue(int year, int month, int day, int hour, int minute, int second, int millisecond)
137 SysTryReturn(NID_BASE,
138 ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
139 (month >= MIN_MONTH && month <= MAX_MONTH) &&
140 (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
141 (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
142 (second >= MIN_SECOND && second <= MAX_SECOND) &&
143 ((millisecond * TICKS_PER_MILLISECOND >= MIN_TICK) && (millisecond * TICKS_PER_MILLISECOND <= MAX_TICK))),
144 E_OUT_OF_RANGE, E_OUT_OF_RANGE,
145 "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
146 GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second, millisecond * TICKS_PER_MILLISECOND);
149 result r = GetDaysInMonth(year, month, daysInMonth);
150 SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
151 SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
152 ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
154 __dateTime.year = year;
155 __dateTime.month = month;
156 __dateTime.day = day;
157 __dateTime.hour = hour;
158 __dateTime.minute = minute;
159 __dateTime.second = ((millisecond * TICKS_PER_MILLISECOND) << INT_HALF_BIT) | second;
164 DateTime::SetValue(long long ticks)
166 return ConvertTicksToDate(ticks, &__dateTime);
170 DateTime::operator =(const DateTime& rhs)
181 DateTime::operator ==(const DateTime& rhs) const
183 return((__dateTime.year == rhs.__dateTime.year) && (__dateTime.month == rhs.__dateTime.month)
184 && (__dateTime.day == rhs.__dateTime.day) && (__dateTime.hour == rhs.__dateTime.hour) &&
185 (__dateTime.minute == rhs.__dateTime.minute) && (__dateTime.second == rhs.__dateTime.second));
189 DateTime::operator !=(const DateTime& rhs) const
191 return !(*this == rhs);
195 DateTime::operator <(const DateTime& rhs) const
197 if (__dateTime.year < rhs.__dateTime.year)
201 if (__dateTime.year > rhs.__dateTime.year)
205 if (__dateTime.month < rhs.__dateTime.month)
209 if (__dateTime.month > rhs.__dateTime.month)
213 if (__dateTime.day < rhs.__dateTime.day)
217 if (__dateTime.day > rhs.__dateTime.day)
221 if (__dateTime.hour < rhs.__dateTime.hour)
225 if (__dateTime.hour > rhs.__dateTime.hour)
229 if (__dateTime.minute < rhs.__dateTime.minute)
233 if (__dateTime.minute > rhs.__dateTime.minute)
237 if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
241 if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
245 if ((__dateTime.second >> INT_HALF_BIT) < (rhs.__dateTime.second >> INT_HALF_BIT))
254 DateTime::operator >(const DateTime& rhs) const
256 if (__dateTime.year > rhs.__dateTime.year)
260 if (__dateTime.year < rhs.__dateTime.year)
264 if (__dateTime.month > rhs.__dateTime.month)
268 if (__dateTime.month < rhs.__dateTime.month)
272 if (__dateTime.day > rhs.__dateTime.day)
276 if (__dateTime.day < rhs.__dateTime.day)
280 if (__dateTime.hour > rhs.__dateTime.hour)
284 if (__dateTime.hour < rhs.__dateTime.hour)
288 if (__dateTime.minute > rhs.__dateTime.minute)
292 if (__dateTime.minute < rhs.__dateTime.minute)
296 if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
300 if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
304 if ((__dateTime.second >> INT_HALF_BIT) > (rhs.__dateTime.second >> INT_HALF_BIT))
313 DateTime::operator <=(const DateTime& rhs) const
315 return ((*this == rhs) || (*this < rhs));
319 DateTime::operator >=(const DateTime& rhs) const
321 return ((*this == rhs) || (*this > rhs));
325 DateTime::Add(const TimeSpan& t)
327 result r = AddTicks(t.GetTicks());
328 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
334 DateTime::AddDays(int days)
336 long long ticks = static_cast< long long >(days) * NUM_OF_TICKS_IN_DAY;
338 result r = AddTicks(ticks);
339 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
345 DateTime::AddHours(int hours)
347 long long ticks = static_cast< long long >(hours) * NUM_OF_TICKS_IN_HOUR;
349 result r = AddTicks(ticks);
350 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
356 DateTime::AddMinutes(int minutes)
358 long long ticks = static_cast< long long >(minutes) * NUM_OF_TICKS_IN_MINUTE;
360 result r = AddTicks(ticks);
361 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
367 DateTime::AddMonths(int months)
372 tmp.__dateTime.year += months / MAX_MONTH; // Get the year to add
374 int tempMonth = tmp.__dateTime.month + months % MAX_MONTH;
375 if (tempMonth > MAX_MONTH) // Month was added and moved to next year
377 tmp.__dateTime.year++;
378 tmp.__dateTime.month = tempMonth - MAX_MONTH;
380 else if (tempMonth <= 0) // Month was subtracted and moved to previous year
382 tmp.__dateTime.year--;
383 tmp.__dateTime.month = MAX_MONTH + tempMonth;
385 else // Keep current year
387 tmp.__dateTime.month += months % MAX_MONTH;
390 // Check the days in Month
391 if (tmp.__dateTime.month != 2) // Current month is not Feb
393 if (tmp.__dateTime.day == 31) // Previous day is 31th
395 result r = SetValue(tmp.__dateTime.year, tmp.__dateTime.month, tmp.__dateTime.day);
396 if (IsFailed(r)) // Current month doesn't have 31th
398 tmp.__dateTime.day = 30; // Set day to 30th
402 else // Current month is Feb
404 if (tmp.__dateTime.day > 28) // Previous day is over 28th
406 if (tmp.IsLeapYear()) // Leap year
408 tmp.__dateTime.day = 29; // Set day to 29th
410 else // Not leap year
412 tmp.__dateTime.day = 28; // Set day to 28th
417 SysTryReturn(NID_BASE, (tmp <= DateTime::GetMaxValue()) && (tmp >= DateTime::GetMinValue()), E_OUT_OF_RANGE,
418 E_OUT_OF_RANGE, "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
426 DateTime::AddSeconds(int seconds)
428 long long ticks = static_cast< long long >(seconds) * NUM_OF_TICKS_IN_SECOND;
430 result r = AddTicks(ticks);
431 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
437 DateTime::AddMilliseconds(long long milliseconds)
439 long long ticks = milliseconds * TICKS_PER_MILLISECOND;
441 result r = AddTicks(ticks);
442 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
448 DateTime::AddTicks(long long ticks)
450 long long total = ConvertDateToTicks(&__dateTime);
453 result r = ConvertTicksToDate(total, &__dateTime);
454 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
460 DateTime::AddYears(int years)
465 int sum = years + tmp.__dateTime.year;
467 SysTryReturn(NID_BASE, (sum >= MIN_YEAR && sum <= _MAX_YEAR), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
468 "[%s] The years(%d) + current year(%d) MUST be within the %d and %d (inclusive).",
469 GetErrorMessage(E_OUT_OF_RANGE), years, __dateTime.year, MIN_YEAR, _MAX_YEAR);
471 tmp.__dateTime.year = sum;
473 // Check the days in Month
474 if (tmp.__dateTime.month == 2) // Feb
476 if (tmp.__dateTime.day > 28)
478 if (tmp.IsLeapYear()) // Check the leap year
480 tmp.__dateTime.day = 29;
484 tmp.__dateTime.day = 28;
495 DateTime::Compare(const DateTime& dt1, const DateTime& dt2)
510 DateTime::CompareTo(const DateTime& value) const
512 return DateTime::Compare(*this, value);
516 DateTime::Equals(const Object& obj) const
518 const DateTime* pOther = dynamic_cast< const DateTime* >(&obj);
524 return (*this == *pOther);
528 DateTime::GetHashCode(void) const
530 TimeSpan t = GetTime();
531 int hash = t.GetHashCode();
532 return (hash ^ (hash >> INT_HALF_BIT));
536 DateTime::GetTimeOfDay(void) const
538 long long total = ConvertDateToSeconds(&__dateTime);
541 midnight.year = __dateTime.year;
542 midnight.month = __dateTime.month;
543 midnight.day = __dateTime.day;
544 midnight.hour = MIN_HOUR;
545 midnight.minute = MIN_MINUTE;
546 midnight.second = MIN_SECOND;
548 long long since = ConvertDateToSeconds(&midnight);
550 long long span = total - since;
552 return (TimeSpan(span * NUM_OF_TICKS_IN_SECOND));
556 DateTime::GetDaysInMonth(int year, int month, int& days)
558 const static int daysInMonth[] = { 0xFF, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
560 SysTryReturn(NID_BASE, (year >= MIN_YEAR && year <= _MAX_YEAR), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
561 "[%s] The year(%d) MUST be within the %d and %d (inclusive).", GetErrorMessage(E_OUT_OF_RANGE),
562 year, MIN_YEAR, _MAX_YEAR);
563 SysTryReturn(NID_BASE, (month >= MIN_MONTH && month <= MAX_MONTH), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
564 "[%s] The month(%d) MUST be within the %d and %d (inclusive).", GetErrorMessage(E_OUT_OF_RANGE),
565 month, MIN_MONTH, MAX_MONTH);
567 if (DateTime::IsLeapYear(year) && month == 2)
569 days = daysInMonth[month] + 1;
573 days = daysInMonth[month];
580 DateTime::Subtract(const TimeSpan& t)
583 long long total = ConvertDateToTicks(&__dateTime);
584 long long span = total - t.GetTicks();
586 SysTryReturn(NID_BASE, span >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] The arguments contain invalid values.",
587 GetErrorMessage(E_OUT_OF_RANGE));
589 SysTryReturn(NID_BASE, span <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
590 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
592 result r = ConvertTicksToDate(span, &__dateTime);
593 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
599 DateTime::ToString(void) const
601 wchar_t date[] = L"01/01/1970 00:00:00";
603 swprintf(date, (sizeof(date) / sizeof(wchar_t)), L"%2d/%2d/%4d %2d:%2d:%2d",
604 __dateTime.month, __dateTime.day, __dateTime.year, __dateTime.hour, __dateTime.minute,
605 (__dateTime.second & LOW_16BIT));
607 if (__dateTime.month < 10)
612 if (__dateTime.day < 10)
617 if (__dateTime.year < 10)
623 else if (__dateTime.year < 100)
628 else if (__dateTime.year < 1000)
633 if (__dateTime.hour < 10)
638 if (__dateTime.minute < 10)
643 if ((__dateTime.second & LOW_16BIT) < 10)
652 DateTime::Parse(const String& str, DateTime& dt)
654 SysTryReturn(NID_BASE,
655 (str.GetLength() == 19
656 && str[2] == L'/' && str[5] == L'/' && str[10] == L' ' && str[13] == L':' && str[16] == L':'),
657 E_INVALID_FORMAT, E_INVALID_FORMAT, ("[%s] The str(%s) is not formatted like 'mm/dd/yyyy hh:mm:ss'."),
658 GetErrorMessage(E_INVALID_FORMAT), str.GetPointer());
660 std::unique_ptr< wchar_t[] > pTmp(new (std::nothrow) wchar_t[5]);
661 SysTryReturn(NID_BASE, pTmp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
662 GetErrorMessage(E_OUT_OF_MEMORY));
664 wchar_t* pMchar = const_cast< wchar_t* >(str.GetPointer());
667 wcsncpy(pTmp.get(), pMchar, 2);
670 int month = static_cast< int >(wcstol(pTmp.get(), null, 10));
673 wcsncpy(pTmp.get(), pMchar + 3, 2);
676 int day = static_cast< int >(wcstol(pTmp.get(), null, 10));
679 wcsncpy(pTmp.get(), pMchar + 6, 4);
682 int year = static_cast< int >(wcstol(pTmp.get(), null, 10));
685 wcsncpy(pTmp.get(), pMchar + 11, 2);
688 int hour = static_cast< int >(wcstol(pTmp.get(), null, 10));
691 wcsncpy(pTmp.get(), pMchar + 14, 2);
694 int minute = static_cast< int >(wcstol(pTmp.get(), null, 10));
697 wcsncpy(pTmp.get(), pMchar + 17, 2);
700 int sec = static_cast< int >(wcstol(pTmp.get(), null, 10));
702 // construct date time
704 result r = tmpDt.SetValue(year, month, day, hour, minute, sec);
705 SysTryReturnResult(NID_BASE, !IsFailed(r), r, ("[%s] Propagating."), GetErrorMessage(r));
713 DateTime::GetYear(void) const
715 return __dateTime.year;
719 DateTime::GetMonth(void) const
721 return __dateTime.month;
725 DateTime::GetDay(void) const
727 return __dateTime.day;
731 DateTime::GetHour(void) const
733 return __dateTime.hour;
737 DateTime::GetMinute(void) const
739 return __dateTime.minute;
743 DateTime::GetSecond(void) const
745 return (__dateTime.second & LOW_16BIT);
749 DateTime::GetMillisecond(void) const
751 return ((__dateTime.second >> INT_HALF_BIT) / TICKS_PER_MILLISECOND);
755 DateTime::GetTicks(void) const
757 return ConvertDateToTicks(&__dateTime);
761 DateTime::GetTicksPerSecond(void)
763 return NUM_OF_TICKS_IN_SECOND;
767 DateTime::GetTime(void) const
769 long long seconds = ConvertDateToSeconds(&__dateTime) - ConvertDateToSeconds(&(DateTime::GetMinValue().__dateTime));
771 return TimeSpan(seconds * NUM_OF_TICKS_IN_SECOND);
775 DateTime::GetMaxValue(void)
777 static DateTime maxValue(_MAX_YEAR, MAX_MONTH, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND, MAX_TICK);
783 DateTime::GetMinValue(void)
785 static DateTime minValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND, MIN_TICK);
791 DateTime::IsLeapYear(void) const
793 return DateTime::IsLeapYear(__dateTime.year);
797 DateTime::IsLeapYear(int year)
799 return year >= 0 && (!(year % 4) && ((year % 100) || !(year % 400)));
802 DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int tick)
803 : __pDateTimeImpl(null)
805 SetValue(year, month, day, hour, minute, (tick << INT_HALF_BIT) | second);
809 DateTime::ConvertTicksToDate(long long ticks, TmDateTime* pDateTime)
811 SysTryReturnResult(NID_BASE, (ticks >= MIN_TICK) && (ticks <= TOTAL_MAX_TICKS), E_OUT_OF_RANGE,
812 "[%s] The arguments (%lld) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), ticks);
821 int totalDays = static_cast< int >(ticks / NUM_OF_TICKS_IN_DAY) + 1;
823 // Get a year and leapYear
824 int year = CountYears(totalDays);
827 bool leapYear = DateTime::IsLeapYear(year);
829 // Get days without year;
830 int tempDays = totalDays - CountDays(year);
833 if (tempDays == 0) // month = 0 , day = 0
842 for (; idx < 12; ++idx)
844 if ((DAYS_IN_LEAP_YEAR[idx] < tempDays) && (tempDays <= DAYS_IN_LEAP_YEAR[idx + 1]))
851 day = tempDays - DAYS_IN_LEAP_YEAR[idx];
857 for (; idx < 12; ++idx)
859 if ((DAYS[idx] < tempDays) && (tempDays <= DAYS[idx + 1]))
866 day = tempDays - DAYS[idx];
869 DateTime dt(year, month, day, 0, 0, 0, 0);
872 tempTicks = static_cast< int >(ticks - ConvertDateToTicks(&(dt.__dateTime)));
873 hour = tempTicks / NUM_OF_TICKS_IN_HOUR;
876 tempTicks -= hour * NUM_OF_TICKS_IN_HOUR;
877 minute = tempTicks / NUM_OF_TICKS_IN_MINUTE;
880 tempTicks -= minute * NUM_OF_TICKS_IN_MINUTE;
881 second = tempTicks / NUM_OF_TICKS_IN_SECOND;
884 tempTicks -= second * NUM_OF_TICKS_IN_SECOND;
885 second = ((tempTicks << INT_HALF_BIT) | second);
887 pDateTime->year = year;
888 pDateTime->month = month;
889 pDateTime->day = day;
890 pDateTime->hour = hour;
891 pDateTime->minute = minute;
892 pDateTime->second = second;
898 DateTime::ConvertDateToTicks(const TmDateTime* pDateTime) const
904 days = CountDays(pDateTime->year);
907 if (pDateTime->month != 0)
909 if (DateTime::IsLeapYear(pDateTime->year))
911 days += DAYS_IN_LEAP_YEAR[pDateTime->month - 1];
915 days += DAYS[pDateTime->month - 1];
920 days += pDateTime->day - 1;
923 ticks = days * NUM_OF_TICKS_IN_DAY;
926 ticks += pDateTime->hour * NUM_OF_TICKS_IN_HOUR;
929 ticks += pDateTime->minute * NUM_OF_TICKS_IN_MINUTE;
932 ticks += ((pDateTime->second) & LOW_16BIT) * NUM_OF_TICKS_IN_SECOND;
935 ticks += ((pDateTime->second) >> INT_HALF_BIT);
941 DateTime::ConvertSecondsToDate(long long seconds, TmDateTime* pDateTime)
943 long long ticks = seconds * NUM_OF_TICKS_IN_SECOND;
945 return ConvertTicksToDate(ticks, pDateTime);
949 DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
951 long long ticks = ConvertDateToTicks(pDateTime);
953 return ticks / NUM_OF_TICKS_IN_SECOND;