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 int DAYS_IN_LEAP_YEAR[] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
58 static const int DAYS[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
59 static const int INT_HALF_BIT = 16;
60 static const int LOW_16BIT = 0xFFFF;
61 static const long long TOTAL_MAX_TICKS = DateTime::GetMaxValue().GetTicks();
63 DateTime::DateTime(void)
64 : __pDateTimeImpl(null)
66 SetValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
69 DateTime::DateTime(const DateTime& value)
70 : __pDateTimeImpl(null)
75 DateTime::~DateTime(void)
80 DateTime::SetValue(const TimeSpan& value)
82 long long total = value.GetTicks();
83 SysTryReturn(NID_BASE, total >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
84 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
86 SysTryReturn(NID_BASE, total <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
87 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
89 return ConvertTicksToDate(total, &__dateTime);
93 DateTime::SetValue(const DateTime& value)
95 __dateTime.year = value.__dateTime.year;
96 __dateTime.month = value.__dateTime.month;
97 __dateTime.day = value.__dateTime.day;
98 __dateTime.hour = value.__dateTime.hour;
99 __dateTime.minute = value.__dateTime.minute;
100 __dateTime.second = value.__dateTime.second;
104 DateTime::SetValue(int year, int month, int day, int hour, int minute, int second)
106 SysTryReturn(NID_BASE,
107 ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
108 (month >= MIN_MONTH && month <= MAX_MONTH) &&
109 (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
110 (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
111 ((second & LOW_16BIT) >= MIN_SECOND && (second & LOW_16BIT) <= MAX_SECOND) &&
112 ((second >> INT_HALF_BIT) >= MIN_TICK && (second >> INT_HALF_BIT) <= MAX_TICK)),
113 E_OUT_OF_RANGE, E_OUT_OF_RANGE,
114 "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
115 GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second & LOW_16BIT, second >> INT_HALF_BIT);
118 result r = GetDaysInMonth(year, month, daysInMonth);
119 SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
120 SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
121 ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
123 __dateTime.year = year;
124 __dateTime.month = month;
125 __dateTime.day = day;
126 __dateTime.hour = hour;
127 __dateTime.minute = minute;
128 __dateTime.second = second;
133 DateTime::SetValue(int year, int month, int day, int hour, int minute, int second, int millisecond)
135 SysTryReturn(NID_BASE,
136 ((year >= MIN_YEAR && year <= _MAX_YEAR) &&
137 (month >= MIN_MONTH && month <= MAX_MONTH) &&
138 (hour >= MIN_HOUR && hour <= MAX_HOUR) &&
139 (minute >= MIN_MINUTE && minute <= MAX_MINUTE) &&
140 (second >= MIN_SECOND && second <= MAX_SECOND) &&
141 ((millisecond * TICKS_PER_MILLISECOND >= MIN_TICK) && (millisecond * TICKS_PER_MILLISECOND <= MAX_TICK))),
142 E_OUT_OF_RANGE, E_OUT_OF_RANGE,
143 "[%s] One of the year(%d), month(%d), day(%d), hour(%d), minute(%d), second(%d) and tick(%d) is out of allowable range.",
144 GetErrorMessage(E_OUT_OF_RANGE), year, month, day, hour, minute, second, millisecond * TICKS_PER_MILLISECOND);
147 result r = GetDaysInMonth(year, month, daysInMonth);
148 SysTryReturn(NID_BASE, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
149 SysTryReturn(NID_BASE, (day >= MIN_DAY && day <= daysInMonth), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
150 ("[%s] day is out of allowable range."), GetErrorMessage(E_OUT_OF_RANGE));
152 __dateTime.year = year;
153 __dateTime.month = month;
154 __dateTime.day = day;
155 __dateTime.hour = hour;
156 __dateTime.minute = minute;
157 __dateTime.second = ((millisecond * TICKS_PER_MILLISECOND) << INT_HALF_BIT) | second;
162 DateTime::SetValue(long long ticks)
164 return ConvertTicksToDate(ticks, &__dateTime);
168 DateTime::operator =(const DateTime& rhs)
179 DateTime::operator ==(const DateTime& rhs) const
181 return((__dateTime.year == rhs.__dateTime.year) && (__dateTime.month == rhs.__dateTime.month)
182 && (__dateTime.day == rhs.__dateTime.day) && (__dateTime.hour == rhs.__dateTime.hour) &&
183 (__dateTime.minute == rhs.__dateTime.minute) && (__dateTime.second == rhs.__dateTime.second));
187 DateTime::operator !=(const DateTime& rhs) const
189 return !(*this == rhs);
193 DateTime::operator <(const DateTime& rhs) const
195 if (__dateTime.year < rhs.__dateTime.year)
199 if (__dateTime.year > rhs.__dateTime.year)
203 if (__dateTime.month < rhs.__dateTime.month)
207 if (__dateTime.month > rhs.__dateTime.month)
211 if (__dateTime.day < rhs.__dateTime.day)
215 if (__dateTime.day > rhs.__dateTime.day)
219 if (__dateTime.hour < rhs.__dateTime.hour)
223 if (__dateTime.hour > rhs.__dateTime.hour)
227 if (__dateTime.minute < rhs.__dateTime.minute)
231 if (__dateTime.minute > rhs.__dateTime.minute)
235 if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
239 if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
243 if ((__dateTime.second >> INT_HALF_BIT) < (rhs.__dateTime.second >> INT_HALF_BIT))
252 DateTime::operator >(const DateTime& rhs) const
254 if (__dateTime.year > rhs.__dateTime.year)
258 if (__dateTime.year < rhs.__dateTime.year)
262 if (__dateTime.month > rhs.__dateTime.month)
266 if (__dateTime.month < rhs.__dateTime.month)
270 if (__dateTime.day > rhs.__dateTime.day)
274 if (__dateTime.day < rhs.__dateTime.day)
278 if (__dateTime.hour > rhs.__dateTime.hour)
282 if (__dateTime.hour < rhs.__dateTime.hour)
286 if (__dateTime.minute > rhs.__dateTime.minute)
290 if (__dateTime.minute < rhs.__dateTime.minute)
294 if ((__dateTime.second & LOW_16BIT) > (rhs.__dateTime.second & LOW_16BIT))
298 if ((__dateTime.second & LOW_16BIT) < (rhs.__dateTime.second & LOW_16BIT))
302 if ((__dateTime.second >> INT_HALF_BIT) > (rhs.__dateTime.second >> INT_HALF_BIT))
311 DateTime::operator <=(const DateTime& rhs) const
313 return ((*this == rhs) || (*this < rhs));
317 DateTime::operator >=(const DateTime& rhs) const
319 return ((*this == rhs) || (*this > rhs));
323 DateTime::Add(const TimeSpan& t)
325 result r = AddTicks(t.GetTicks());
326 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
332 DateTime::AddDays(int days)
334 long long ticks = static_cast< long long >(days) * NUM_OF_TICKS_IN_DAY;
336 result r = AddTicks(ticks);
337 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
343 DateTime::AddHours(int hours)
345 long long ticks = static_cast< long long >(hours) * NUM_OF_TICKS_IN_HOUR;
347 result r = AddTicks(ticks);
348 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
354 DateTime::AddMinutes(int minutes)
356 long long ticks = static_cast< long long >(minutes) * NUM_OF_TICKS_IN_MINUTE;
358 result r = AddTicks(ticks);
359 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
365 DateTime::AddMonths(int months)
370 tmp.__dateTime.year += months / MAX_MONTH; // Get the year to add
372 int tempMonth = tmp.__dateTime.month + months % MAX_MONTH;
373 if (tempMonth > MAX_MONTH) // Month was added and moved to next year
375 tmp.__dateTime.year++;
376 tmp.__dateTime.month = tempMonth - MAX_MONTH;
378 else if (tempMonth <= 0) // Month was subtracted and moved to previous year
380 tmp.__dateTime.year--;
381 tmp.__dateTime.month = MAX_MONTH + tempMonth;
383 else // Keep current year
385 tmp.__dateTime.month += months % MAX_MONTH;
388 // Check the days in Month
389 if (tmp.__dateTime.month != 2) // Current month is not Feb
391 if (tmp.__dateTime.day == 31) // Previous day is 31th
393 result r = SetValue(tmp.__dateTime.year, tmp.__dateTime.month, tmp.__dateTime.day);
394 if (IsFailed(r)) // Current month doesn't have 31th
396 tmp.__dateTime.day = 30; // Set day to 30th
400 else // Current month is Feb
402 if (tmp.__dateTime.day > 28) // Previous day is over 28th
404 if (tmp.IsLeapYear()) // Leap year
406 tmp.__dateTime.day = 29; // Set day to 29th
408 else // Not leap year
410 tmp.__dateTime.day = 28; // Set day to 28th
415 SysTryReturn(NID_BASE, (tmp <= DateTime::GetMaxValue()) && (tmp >= DateTime::GetMinValue()), E_OUT_OF_RANGE,
416 E_OUT_OF_RANGE, "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
424 DateTime::AddSeconds(int seconds)
426 long long ticks = static_cast< long long >(seconds) * NUM_OF_TICKS_IN_SECOND;
428 result r = AddTicks(ticks);
429 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
435 DateTime::AddMilliseconds(long long milliseconds)
437 long long ticks = milliseconds * TICKS_PER_MILLISECOND;
439 result r = AddTicks(ticks);
440 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
446 DateTime::AddTicks(long long ticks)
448 long long total = ConvertDateToTicks(&__dateTime);
451 result r = ConvertTicksToDate(total, &__dateTime);
452 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
458 DateTime::AddYears(int years)
463 int sum = years + tmp.__dateTime.year;
465 SysTryReturn(NID_BASE, (sum >= MIN_YEAR && sum <= _MAX_YEAR), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
466 "[%s] The years(%d) + current year(%d) MUST be within the %d and %d (inclusive).",
467 GetErrorMessage(E_OUT_OF_RANGE), years, __dateTime.year, MIN_YEAR, _MAX_YEAR);
469 tmp.__dateTime.year = sum;
471 // Check the days in Month
472 if (tmp.__dateTime.month == 2) // Feb
474 if (tmp.__dateTime.day > 28)
476 if (tmp.IsLeapYear()) // Check the leap year
478 tmp.__dateTime.day = 29;
482 tmp.__dateTime.day = 28;
493 DateTime::Compare(const DateTime& dt1, const DateTime& dt2)
508 DateTime::CompareTo(const DateTime& value) const
510 return DateTime::Compare(*this, value);
514 DateTime::Equals(const Object& obj) const
516 const DateTime* pOther = dynamic_cast< const DateTime* >(&obj);
522 return (*this == *pOther);
526 DateTime::GetHashCode(void) const
528 TimeSpan t = GetTime();
529 int hash = t.GetHashCode();
530 return (hash ^ (hash >> INT_HALF_BIT));
534 DateTime::GetTimeOfDay(void) const
536 long long total = ConvertDateToSeconds(&__dateTime);
539 midnight.year = __dateTime.year;
540 midnight.month = __dateTime.month;
541 midnight.day = __dateTime.day;
542 midnight.hour = MIN_HOUR;
543 midnight.minute = MIN_MINUTE;
544 midnight.second = MIN_SECOND;
546 long long since = ConvertDateToSeconds(&midnight);
548 long long span = total - since;
550 return (TimeSpan(span * NUM_OF_TICKS_IN_SECOND));
554 DateTime::GetDaysInMonth(int year, int month, int& days)
556 const static int daysInMonth[] = { 0xFF, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
558 SysTryReturn(NID_BASE, (year >= MIN_YEAR && year <= _MAX_YEAR), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
559 "[%s] The year(%d) MUST be within the %d and %d (inclusive).", GetErrorMessage(E_OUT_OF_RANGE),
560 year, MIN_YEAR, _MAX_YEAR);
561 SysTryReturn(NID_BASE, (month >= MIN_MONTH && month <= MAX_MONTH), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
562 "[%s] The month(%d) MUST be within the %d and %d (inclusive).", GetErrorMessage(E_OUT_OF_RANGE),
563 month, MIN_MONTH, MAX_MONTH);
565 if (DateTime::IsLeapYear(year) && month == 2)
567 days = daysInMonth[month] + 1;
571 days = daysInMonth[month];
578 DateTime::Subtract(const TimeSpan& t)
581 long long total = ConvertDateToTicks(&__dateTime);
582 long long span = total - t.GetTicks();
584 SysTryReturn(NID_BASE, span >= MIN_TICK, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] The arguments contain invalid values.",
585 GetErrorMessage(E_OUT_OF_RANGE));
587 SysTryReturn(NID_BASE, span <= TOTAL_MAX_TICKS, E_OUT_OF_RANGE, E_OUT_OF_RANGE,
588 "[%s] The value of the argument is outside the valid range.", GetErrorMessage(E_OUT_OF_RANGE));
590 result r = ConvertTicksToDate(span, &__dateTime);
591 SysTryReturnResult(NID_BASE, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
597 DateTime::ToString(void) const
599 wchar_t date[] = L"01/01/1970 00:00:00";
601 swprintf(date, (sizeof(date) / sizeof(wchar_t)), L"%2d/%2d/%4d %2d:%2d:%2d",
602 __dateTime.month, __dateTime.day, __dateTime.year, __dateTime.hour, __dateTime.minute,
603 (__dateTime.second & LOW_16BIT));
605 if (__dateTime.month < 10)
610 if (__dateTime.day < 10)
615 if (__dateTime.year < 10)
621 else if (__dateTime.year < 100)
626 else if (__dateTime.year < 1000)
631 if (__dateTime.hour < 10)
636 if (__dateTime.minute < 10)
641 if ((__dateTime.second & LOW_16BIT) < 10)
650 DateTime::Parse(const String& str, DateTime& dt)
652 SysTryReturn(NID_BASE,
653 (str.GetLength() == 19
654 && str[2] == L'/' && str[5] == L'/' && str[10] == L' ' && str[13] == L':' && str[16] == L':'),
655 E_INVALID_FORMAT, E_INVALID_FORMAT, ("[%s] The str(%s) is not formatted like 'mm/dd/yyyy hh:mm:ss'."),
656 GetErrorMessage(E_INVALID_FORMAT), str.GetPointer());
658 std::unique_ptr< wchar_t[] > pTmp(new (std::nothrow) wchar_t[5]);
659 SysTryReturn(NID_BASE, pTmp != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
660 GetErrorMessage(E_OUT_OF_MEMORY));
662 wchar_t* pMchar = const_cast< wchar_t* >(str.GetPointer());
665 wcsncpy(pTmp.get(), pMchar, 2);
668 int month = static_cast< int >(wcstol(pTmp.get(), null, 10));
671 wcsncpy(pTmp.get(), pMchar + 3, 2);
674 int day = static_cast< int >(wcstol(pTmp.get(), null, 10));
677 wcsncpy(pTmp.get(), pMchar + 6, 4);
680 int year = static_cast< int >(wcstol(pTmp.get(), null, 10));
683 wcsncpy(pTmp.get(), pMchar + 11, 2);
686 int hour = static_cast< int >(wcstol(pTmp.get(), null, 10));
689 wcsncpy(pTmp.get(), pMchar + 14, 2);
692 int minute = static_cast< int >(wcstol(pTmp.get(), null, 10));
695 wcsncpy(pTmp.get(), pMchar + 17, 2);
698 int sec = static_cast< int >(wcstol(pTmp.get(), null, 10));
700 // construct date time
702 result r = tmpDt.SetValue(year, month, day, hour, minute, sec);
703 SysTryReturnResult(NID_BASE, !IsFailed(r), r, ("[%s] Propagating."), GetErrorMessage(r));
711 DateTime::GetYear(void) const
713 return __dateTime.year;
717 DateTime::GetMonth(void) const
719 return __dateTime.month;
723 DateTime::GetDay(void) const
725 return __dateTime.day;
729 DateTime::GetHour(void) const
731 return __dateTime.hour;
735 DateTime::GetMinute(void) const
737 return __dateTime.minute;
741 DateTime::GetSecond(void) const
743 return (__dateTime.second & LOW_16BIT);
747 DateTime::GetMillisecond(void) const
749 return ((__dateTime.second >> INT_HALF_BIT) / TICKS_PER_MILLISECOND);
753 DateTime::GetTicks(void) const
755 return ConvertDateToTicks(&__dateTime);
759 DateTime::GetTicksPerSecond(void)
761 return NUM_OF_TICKS_IN_SECOND;
765 DateTime::GetTime(void) const
767 long long seconds = ConvertDateToSeconds(&__dateTime) - ConvertDateToSeconds(&(DateTime::GetMinValue().__dateTime));
769 return TimeSpan(seconds * NUM_OF_TICKS_IN_SECOND);
773 DateTime::GetMaxValue(void)
775 static DateTime maxValue(_MAX_YEAR, MAX_MONTH, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND, MAX_TICK);
781 DateTime::GetMinValue(void)
783 static DateTime minValue(MIN_YEAR, MIN_MONTH, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND, MIN_TICK);
789 DateTime::IsLeapYear(void) const
791 return DateTime::IsLeapYear(__dateTime.year);
795 DateTime::IsLeapYear(int year)
797 return year >= 0 && (!(year % 4) && ((year % 100) || !(year % 400)));
800 DateTime::DateTime(int year, int month, int day, int hour, int minute, int second, int tick)
801 : __pDateTimeImpl(null)
803 SetValue(year, month, day, hour, minute, (tick << INT_HALF_BIT) | second);
807 DateTime::ConvertTicksToDate(long long ticks, TmDateTime* pDateTime)
809 SysTryReturnResult(NID_BASE, (ticks >= MIN_TICK) && (ticks <= TOTAL_MAX_TICKS), E_OUT_OF_RANGE,
810 "[%s] The arguments (%lld) contain invalid values.", GetErrorMessage(E_OUT_OF_RANGE), ticks);
819 int totalDays = static_cast< int >(ticks / NUM_OF_TICKS_IN_DAY) + 1;
821 // Get a year and leapYear
822 int year = CountYears(totalDays);
825 bool leapYear = DateTime::IsLeapYear(year);
827 // Get days without year;
828 int tempDays = totalDays - CountDays(year);
831 if (tempDays == 0) // month = 0 , day = 0
840 for (; idx < 12; ++idx)
842 if ((DAYS_IN_LEAP_YEAR[idx] < tempDays) && (tempDays <= DAYS_IN_LEAP_YEAR[idx + 1]))
849 day = tempDays - DAYS_IN_LEAP_YEAR[idx];
855 for (; idx < 12; ++idx)
857 if ((DAYS[idx] < tempDays) && (tempDays <= DAYS[idx + 1]))
864 day = tempDays - DAYS[idx];
867 DateTime dt(year, month, day, 0, 0, 0, 0);
870 tempTicks = static_cast< int >(ticks - ConvertDateToTicks(&(dt.__dateTime)));
871 hour = tempTicks / NUM_OF_TICKS_IN_HOUR;
874 tempTicks -= hour * NUM_OF_TICKS_IN_HOUR;
875 minute = tempTicks / NUM_OF_TICKS_IN_MINUTE;
878 tempTicks -= minute * NUM_OF_TICKS_IN_MINUTE;
879 second = tempTicks / NUM_OF_TICKS_IN_SECOND;
882 tempTicks -= second * NUM_OF_TICKS_IN_SECOND;
883 second = ((tempTicks << INT_HALF_BIT) | second);
885 pDateTime->year = year;
886 pDateTime->month = month;
887 pDateTime->day = day;
888 pDateTime->hour = hour;
889 pDateTime->minute = minute;
890 pDateTime->second = second;
896 DateTime::ConvertDateToTicks(const TmDateTime* pDateTime) const
902 days = CountDays(pDateTime->year);
905 if (pDateTime->month != 0)
907 if (DateTime::IsLeapYear(pDateTime->year))
909 days += DAYS_IN_LEAP_YEAR[pDateTime->month - 1];
913 days += DAYS[pDateTime->month - 1];
918 days += pDateTime->day - 1;
921 ticks = days * NUM_OF_TICKS_IN_DAY;
924 ticks += pDateTime->hour * NUM_OF_TICKS_IN_HOUR;
927 ticks += pDateTime->minute * NUM_OF_TICKS_IN_MINUTE;
930 ticks += ((pDateTime->second) & LOW_16BIT) * NUM_OF_TICKS_IN_SECOND;
933 ticks += ((pDateTime->second) >> INT_HALF_BIT);
939 DateTime::ConvertSecondsToDate(long long seconds, TmDateTime* pDateTime)
941 long long ticks = seconds * NUM_OF_TICKS_IN_SECOND;
943 return ConvertTicksToDate(ticks, pDateTime);
947 DateTime::ConvertDateToSeconds(const TmDateTime* pDateTime) const
949 long long ticks = ConvertDateToTicks(pDateTime);
951 return ticks / NUM_OF_TICKS_IN_SECOND;