2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLclCalendar.h
20 * @brief This is the header file for the %Calendar class.
22 * This header file contains the declarations of the %Calendar class.
25 #ifndef _FLCL_CALENDAR_H_
26 #define _FLCL_CALENDAR_H_
29 #include <FLclLocale.h>
30 #include <FLclTimeZone.h>
32 namespace Tizen { namespace Locales
36 * @brief This class provides methods for displaying a calendar.
40 * The %Calendar class is an abstract base class for displaying a calendar. It is used to convert between the Tizen::Base::DateTime instance and a set of time fields, such as TIME_FIELD_YEAR, TIME_FIELD_MONTH, and TIME_FIELD_DAY_OF_MONTH.
41 * Subclasses of %Calendar interpret %Tizen::Base::DateTime according to the rules of a specific calendar system. GregorianCalendar is commonly used.
43 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/locales/calendar.htm">Calendar</a>.
45 * @see Tizen::Locales::TimeZone
47 * The following example demonstrates how to use the %Calendar class to set or add the time field.
54 using namespace Tizen::Base;
55 using namespace Tizen::Locales;
58 MyClass::CalendarExample(void)
61 String timeZoneName(L"Europe/Paris");
62 TimeZone timeZone(offset, timeZoneName);
64 Calendar* pCalendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN);
65 pCalendar->SetTime(2012,7,18);
67 // Increase one day. The date will be 2012/7/19
68 pCalendar->AddTimeField(TIME_FIELD_DAY_OF_MONTH, 1);
70 // Decrease two months. The date will be 2012/5/19
71 pCalendar->AddTimeField(TIME_FIELD_MONTH, -2);
77 #define GET_TIME_FIELD_MASK(X) (static_cast<int>(1 << (X)))
81 * Defines the time fields for date and time. @n
82 * This enum is used in %Calendar.
88 TIME_FIELD_ERA, /**< Era : 0 - BC, 1 - AD */
89 TIME_FIELD_YEAR, /**< Year : 1-based */
90 TIME_FIELD_MONTH, /**< Month : 1-based (1~13)*/
91 TIME_FIELD_WEEK_OF_YEAR, /**< Week of Year : 1-based (1~53) */
92 TIME_FIELD_WEEK_OF_MONTH, /**< Week of Month : 1-based (1~5, may be specified as 0) */
93 TIME_FIELD_DAY_OF_MONTH, /**< Date : 1-based (1~31) */
94 TIME_FIELD_DAY_OF_YEAR, /**< Day of Year : 1-based (1~366) */
95 TIME_FIELD_DAY_OF_WEEK, /**< Day of Week : 1-based (1~7) */
96 TIME_FIELD_DAY_OF_WEEK_IN_MONTH, /**< Day of Week in Month : 1-based (1~5, may be specified as -1) */
97 TIME_FIELD_AM_PM, /**< AmPm : 0 - AM, 1 - PM */
98 TIME_FIELD_HOUR, /**< Hour : 0-based (0~11) */
99 TIME_FIELD_HOUR_OF_DAY, /**< Hour of Day : 0-based (0~23) */
100 TIME_FIELD_MINUTE, /**< Minute : 0-based (0~59) */
101 TIME_FIELD_SECOND, /**< Second : 0-based (0~59) */
102 TIME_FIELD_MILLISECOND, /**< Millisecond : 0-based (0~999) */
103 TIME_FIELD_ZONE_OFFSET, /**< Time Zone Offset : 0-based (-43200000~54000000 in milliseconds) */
104 TIME_FIELD_DST_OFFSET, /**< Daylight Saving Offset : 0-based (0~3600000 in milliseconds)*/
105 TIME_FIELD_FIELD_COUNT /**< The number of time field */
108 class _OSP_EXPORT_ Calendar
109 : public Tizen::Base::Object
113 * This is the destructor for this class. @n
114 * This destructor overrides Tizen::Base::Object::~Object().
118 virtual ~Calendar(void);
121 * Adds the specified amount to the given time field, based on the calendar rules. @n
122 * It is equivalent to calling SetTimeField(field, GetTimeField(field)+amount) with two adjustments. @n
124 * @b Add @b Rule1: The value of the time field @c field after the call minus the value of the field
125 * before the call is delta modulo any overflow that has occurred in the field.
126 * Overflow occurs when a time field value exceeds its range and, as a result, the next larger field
127 * is incremented or decremented and the field value is adjusted back into its range. @n
129 * @b Add @b Rule2: If a smaller field is expected to be invariant, but it is impossible for it to be
130 * equal to its prior value because of changes in its minimum or maximum value after the time field @c field
131 * is changed, then its value is adjusted to be as close as possible to its expected value. @n
133 * A smaller field represents a smaller unit of time. TIME_FIELD_HOUR is a smaller field than TIME_FIELD_DAY_OF_MONTH.
134 * No adjustment is made to smaller fields that are not expected to be invariant.
135 * The calendar system determines what fields are expected to be invariant.
137 * In addition, this method forces re-computation of the calendar's milliseconds and
138 * all time fields immediately. @n
140 * For example, consider a GregorianCalendar set to Oct 31, 2004.
141 * Calling AddTimeField(TIME_FIELD_MONTH, 13) sets the calendar to Nov 30, 2005. @n
142 * The TIME_FIELD_MONTH field is set to NOVEMBER by @b Rule1, since adding 13 months to October gives the
143 * November of the next year.
144 * Since, the TIME_FIELD_DAY_OF_MONTH cannot be 31 in November in a %GregorianCalendar, the TIME_FIELD_DAY_OF_MONTH is set to 30 by @b Rule2.
147 * @brief <i> [Compatibility] </i>
151 * @compatibility This method has compatibility issues with OSP compatible applications. @n
152 * For more information, see @ref CompCalendarAddTimeFieldPage "here".
155 * @return An error code
156 * @param[in] field The time field
157 * @param[in] amount The amount to add
158 * @exception E_SUCCESS The method is successful.
159 * @exception E_INVALID_ARG The specified @c field is invalid.
161 virtual result AddTimeField(TimeField field, int amount) = 0;
165 * @page CompCalendarAddTimeFieldPage Compatibility for AddTimeField()
166 * @section CompCalendarAddTimeFieldIssueSection Issues
167 * Implementation of this method in OSP compatible applications has the following issue: @n
168 * -# The method returns E_INVALID_STATE if the time field is invalid.
170 * @section CompCalendarAddTimeFieldSolutionSection Resolutions
171 * This issue has been resolved in Tizen.
173 * @par When working in Tizen:
174 * -# The method returns E_INVALID_ARG if the time field is invalid.
179 * Compares the current instance of %Calendar with the specified instance.
182 * @brief <i> [Compatibility] </i>
186 * @compatibility This method has compatibility issues with OSP compatible applications. @n
187 * For more information, see @ref CompCalendarAfterPage "here".
190 * @return An error code
191 * @param[in] otherCalendar The instance of %Calendar to compare
192 * @param[out] after Set to @c true if the current instance of %Calendar is after the specified instance of %Calendar, @n
194 * @exception E_SUCCESS The method is successful.
195 * @exception E_INVALID_ARG The specified @c otherCalendar is invalid.
196 * @exception E_INVALID_STATE In this method, the time fields of this instance are calculated. @n
197 * If any time field value previously set is invalid, this exception is returned.
198 * @exception E_OUT_OF_RANGE In this method, the time fields of this instance are calculated. @n
199 * If the value of the time fields goes out of range, this exception is returned.
201 result After(const Calendar& otherCalendar, bool& after);
205 * @page CompCalendarAfterPage Compatibility for After()
206 * @section CompCalendarAfterIssueSection Issues
207 * Implementation of this method in OSP compatible applications has the following issue: @n
208 * -# The method returns E_INVALID_STATE and E_OUT_OF_RANGE if the instance of %Calendar to be compared is invalid.
210 * @section CompCalendarAfterSolutionSection Resolutions
211 * This issue has been resolved in Tizen.
213 * @par When working in Tizen:
214 * -# The method returns E_INVALID_ARG if the instance of %Calendar to be compared is invalid.
215 * -# The method returns E_INVALID_STATE if any time field value previously set is invalid.
216 * -# The method returns E_OUT_OF_RANGE if the value of the time fields goes out of range.
221 * Compares the current instance of %Calendar with the specified instance.
224 * @brief <i> [Compatibility] </i>
228 * @compatibility This method has compatibility issues with OSP compatible applications. @n
229 * For more information, see @ref CompCalendarBeforePage "here".
232 * @return An error code
233 * @param[in] otherCalendar The instance of %Calendar to compare
234 * @param[out] before Set to @c true if the current instance of %Calendar is before the specified instance of %Calendar, @n
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_INVALID_ARG The specified @c otherCalendar is invalid.
238 * @exception E_INVALID_STATE In this method, the time fields of this instance are calculated. @n
239 * If any time field value previously set is invalid, this exception is returned.
240 * @exception E_OUT_OF_RANGE In this method, the time fields of this instance are calculated. @n
241 * If the value of the time fields goes out of range, this exception is returned.
243 result Before(const Calendar& otherCalendar, bool& before);
247 * @page CompCalendarBeforePage Compatibility for Before()
248 * @section CompCalendarBeforeIssueSection Issues
249 * Implementation of this method in OSP compatible applications has the following issue: @n
250 * -# The method returns E_INVALID_STATE and E_OUT_OF_RANGE if the instance of %Calendar to be compared is invalid.
252 * @section CompCalendarBeforeSolutionSection Resolutions
253 * This issue has been resolved in Tizen.
255 * @par When working in Tizen:
256 * -# The method returns E_INVALID_ARG if the instance of %Calendar to be compared is invalid.
257 * -# The method returns E_INVALID_STATE if any time field value previously set is invalid.
258 * -# The method returns E_OUT_OF_RANGE if the value of the time fields goes out of range.
263 * Clears all the time fields and sets it to @c 0. @n
264 * Zero is not the default value for each field. It means the field is cleared.
268 * @return An error code
269 * @exception E_SUCCESS The method is successful.
274 * Clears the specified time field and sets it to @c 0. @n
275 * Zero is not the default value for each field. It means the field is cleared.
279 * @return An error code
280 * @param[in] field The time field to clear
281 * @exception E_SUCCESS The method is successful.
283 result Clear(TimeField field);
286 * Checks whether the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Calendar.
290 * @return @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Calendar, @n
292 * @param[in] obj An instance of Tizen::Base::Object to compare
294 virtual bool Equals(const Tizen::Base::Object& obj) const;
297 * Gets the hash value of the current instance.
301 * @return The hash value of the current instance
303 virtual int GetHashCode(void) const;
306 * Rolls up or down as per the specified @c amount in the specified time field without changing the larger fields (for example, TIME_FIELD_YEAR field cannot be changed when the input field is TIME_FIELD_MONTH). @n
307 * If the specified @c amount is negative, the amount value is deducted from the specified time field value.
308 * In this method, the time field of this instance is operated upon. If the value of the specified @c field goes out of range, E_OUT_OF_RANGE is returned.
311 * @brief <i> [Compatibility] </i>
315 * @compatibility This method has compatibility issues with OSP compatible applications. @n
316 * For more information, see @ref CompCalendarRollPage "here".
319 * @return An error code
320 * @param[in] field The time field to roll
321 * @param[in] amount The amount to add to the time field
322 * @exception E_SUCCESS The method is successful.
323 * @exception E_INVALID_ARG The specified @c field is invalid (for example, TIME_FIELD_DST_OFFSET, TIME_FIELD_ZONE_OFFSET).
324 * @exception E_OUT_OF_RANGE In this method, the time fields of this instance are calculated. @n
325 * If the value of the time fields goes out of range, this exception is returned.
327 virtual result Roll(TimeField field, int amount);
331 * @page CompCalendarRollPage Compatibility for Roll()
332 * @section CompCalendarRollIssueSection Issues
333 * Implementation of this method in OSP compatible applications has the following issue: @n
334 * -# The method returns E_INVALID_STATE if the time field is invalid.
336 * @section CompCalendarRollSolutionSection Resolutions
337 * This issue has been resolved in Tizen.
339 * @par When working in Tizen:
340 * -# The method returns E_INVALID_ARG if the time field is invalid.
345 * Sets the specified time field with the specified @c value. @n
346 * This sets an internal member variable to indicate that the field has been changed.
347 * Although the time field is changed, the milliseconds of %Calendar are not recomputed
348 * until GetTimeField(), GetTime(), or GetTimeInMillisec() is called.
349 * Thus, even if you call this method several times, unnecessary multiple computations are not triggered. @n
351 * As a result of changing a field using SetTimeField(), other fields may also change
352 * depending on the field, the field value, and the calendar system. @n
354 * For example, consider a GregorianCalendar set to Oct. 31, 2004.
355 * Calling SetTimeField(TIME_FIELD_MONTH, NOVEMBER) sets the calendar to Nov 31, 2004. @n
356 * But, if you call GetTime(), then Dec 1, 2004 is returned because Nov 31, 2004 does not exist.
357 * However, a call to SetTimeField(TIME_FIELD_MONTH, SEPTEMBER) before a call to GetTime() sets the calendar
358 * to Sep 30, 2004, since no re-computation has occurred after the first call to SetTimeField().
360 * The value of field is not affected by it being local time or UTC time.
361 * The value is only overwritten.
365 * @return An error code
366 * @param[in] field The time field to set
367 * @param[in] value The value to set
368 * @exception E_SUCCESS The method is successful.
369 * @exception E_OUT_OF_RANGE The value is out of range in lenient mode.
370 * @exception E_INVALID_ARG The specified @c field is invalid.
372 result SetTimeField(TimeField field, int value);
375 * Sets the first day of the week.
379 * @return An error code
380 * @param[in] dayOfWeek The value to set as the first day of the week
381 * @exception E_SUCCESS The method is successful.
382 * @exception E_INVALID_ARG The specified @c dayOfWeek is invalid.
384 result SetFirstDayOfWeek(DayOfWeek dayOfWeek);
387 * Sets the leniency of date and time interpretations.
391 * @return An error code
392 * @param[in] lenient Set to @c true if the date and time interpretation is set to lenient, @n
394 * @exception E_SUCCESS The method is successful.
396 result SetLenient(bool lenient);
399 * Sets the minimal days required in the first week.
403 * @return An error code
404 * @param[in] value The minimal days required in the first week
405 * @exception E_SUCCESS The method is successful.
407 result SetMinDaysInFirstWeek(short value);
410 * Sets the value of year, month, day, hour, minute, and seconds. @n
411 * The date and time are local time.
415 * @return An error code
416 * @param[in] year The value to set for year
417 * @param[in] month The value to set for month @n
418 * The indexing is 1-based. Therefore, 1 means January.
419 * @param[in] day The value to set for day
420 * @param[in] hour The value to set for hour
421 * @param[in] minute The value to set for minute
422 * @param[in] second The value to set for second
423 * @exception E_SUCCESS The method is successful.
424 * @exception E_OUT_OF_RANGE A time field or its value is out of range in lenient mode.
426 result SetTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0);
429 * Sets the calendar's current time with the specified Tizen::Base::DateTime.
433 * @return An error code
434 * @param[in] dateTime The Tizen::Base::DateTime instance to set
435 * @exception E_SUCCESS The method is successful.
436 * @remarks The time specified is the local time.
438 result SetTime(const Tizen::Base::DateTime& dateTime);
441 * Sets the current time of this %Calendar instance with the specified value.
445 * @return An error code
446 * @param[in] millisec The new time in milliseconds from the starting day (Jan 1, 1.)
447 * @exception E_SUCCESS The method is successful.
448 * @exception E_OUT_OF_RANGE A time field or its value is out of range.
450 result SetTimeInMillisec(long long millisec);
453 * Sets the time zone of the calendar to the specified time zone.
457 * @return An error code
458 * @param[in] timeZone The time zone to set
459 * @exception E_SUCCESS The method is successful.
461 result SetTimeZone(const TimeZone& timeZone);
464 * Gets the actual maximum value that the specified field can have, given the current date. @n
465 * For example, if the current date is "Feb 10, 2004" and the time field specified is TIME_FIELD_DAY_OF_MONTH, then the actual
466 * maximum value for this time field is 29.
470 * @return An integer value indicating the actual maximum value
471 * @param[in] field The time field
472 * @exception E_SUCCESS The method is successful.
473 * @exception E_INVALID_ARG The specified @c field is invalid.
474 * @remarks The specific error code can be accessed using the GetLastResult() method.
476 virtual int GetActualMaxTimeField(TimeField field) const;
479 * Gets the actual minimum value that the specified time field can have, given the current date. @n
480 * For the Gregorian calendar, this is the same as GetMinTimeField() and
481 * GetGreatestMinTimeField().
485 * @return An integer value indicating the actual minimum value
486 * @param[in] field The time field
487 * @exception E_SUCCESS The method is successful.
488 * @exception E_INVALID_ARG The specified @c field is invalid.
489 * @exception E_SYSTEM A system error has occurred.
490 * @remarks The specific error code can be accessed using the GetLastResult() method.
492 virtual int GetActualMinTimeField(TimeField field) const;
495 * Gets the value of the first day of the week. @n
496 * For example, in USA, the first day of the week is SUNDAY. But, it is MONDAY in France.
500 * @return An integer value indicating the first day of the week, @n
501 * else @c -1 if the method fails
503 int GetFirstDayOfWeek(void) const;
506 * Gets the greatest minimum value that the specified time field can have.
510 * @return An integer value indicating the greatest minimum value for the specified time field
511 * @param[in] field The time field
512 * @exception E_SUCCESS The method is successful.
513 * @exception E_INVALID_ARG The specified @c field is invalid.
514 * @exception E_SYSTEM A system error has occurred.
515 * @remarks The specific error code can be accessed using the GetLastResult() method.
517 virtual int GetGreatestMinTimeField(TimeField field) const;
520 * Gets the least maximum value that the specified time field can have.
524 * @return An integer value indicating the least maximum value for the specified time field
525 * @param[in] field The time field
526 * @exception E_SUCCESS The method is successful.
527 * @exception E_INVALID_ARG The specified @c field is invalid.
528 * @exception E_SYSTEM A system error has occurred.
529 * @remarks The specific error code can be accessed using the GetLastResult() method.
531 virtual int GetLeastMaxTimeField(TimeField field) const;
534 * Gets the maximum value that the specified time field can have.
538 * @return An integer value indicating the maximum value for the specified time field
539 * @param[in] field The time field
540 * @exception E_SUCCESS The method is successful.
541 * @exception E_INVALID_ARG The specified @c field is invalid.
542 * @exception E_SYSTEM A system error has occurred.
543 * @remarks The specific error code can be accessed using the GetLastResult() method.
545 virtual int GetMaxTimeField(TimeField field) const;
548 * Gets the minimum value that the specified time field can have.
552 * @return An integer value indicating the minimum value for the specified time field
553 * @param[in] field The time field
554 * @exception E_SUCCESS The method is successful.
555 * @exception E_INVALID_ARG The specified @c field is invalid.
556 * @exception E_SYSTEM A system error has occurred.
557 * @remarks The specific error code can be accessed using the GetLastResult() method.
559 virtual int GetMinTimeField(TimeField field) const;
562 * Gets the minimum number of days required in the first week of the year. @n
563 * For example, if the first week is defined as the one that contains the first day of
564 * the first month of a year, this method returns @c 1.
568 * @return An integer value indicating the minimum number of days required in the first week
570 int GetMinDaysInFirstWeek(void) const;
573 * Gets the date and time of the current instance of %Calendar.
577 * @return An instance of Tizen::Base::DateTime with the current time in local time
578 * @remarks The time specified is local time.
580 Tizen::Base::DateTime GetTime(void) const;
583 * Gets the value of the specified time field.
587 * @return An integer value indicating the value of the specified time field
589 * @param[in] field The given time field
590 * @exception E_SUCCESS The method is successful.
591 * @exception E_INVALID_ARG The specified @c field is invalid.
592 * @exception E_SYSTEM A system error has occurred.
593 * @remarks This method is semantically const, but may alter the instance in memory.
594 * All fields are re-computed if any field is invalid.
595 * The specific error code can be accessed using the GetLastResult() method.
597 int GetTimeField(TimeField field) const;
600 * Gets the current time of the instance in the @c long format.
604 * @return An error code
605 * @param[out] millisec The current time in milliseconds from starting day (Jan 1, 1.)
606 * @exception E_SUCCESS The method is successful.
607 * @exception E_INVALID_STATE In this method, the time fields of this instance are calculated. @n
608 * If any time field value previously set is invalid, this exception is returned.
609 * @exception E_OUT_OF_RANGE The value of the argument is out of the valid range defined by the method.
611 result GetTimeInMillisec(long long& millisec) const;
614 * Gets a reference to the time zone owned by this instance of %Calendar.
618 * @return The TimeZone instance associated with the current instance of %Calendar
619 * @remarks The returned reference is valid only until the SetTimeZone() method is called or this instance of %Calendar is destroyed.
622 TimeZone GetTimeZone(void) const;
625 * Gets the calendar type of the current instance of %Calendar.
629 * @return An instance of CalendarType representing the calendar type of the current instance of %Calendar @n
630 * For example, CALENDAR_GREGORIAN.
632 virtual CalendarType GetType(void) const = 0;
635 * Checks whether the current date for the instance of %Calendar is in Daylight Saving Time (DST).
639 * @return An error code
640 * @param[out] isInDst Set to @c true if the current date is in DST, @n
642 * @exception E_SUCCESS The method is successful.
643 * @exception E_INVALID_STATE In this method, the time fields of this instance are calculated. @n
644 * If any time field value previously set is invalid, this exception is returned.
645 * @exception E_OUT_OF_RANGE A time field or its value is out of range. @n
646 * In this method, the time fields of this instance are calculated. If the value of the time fields goes out of range, this exception is returned.
648 virtual result IsInDst(bool& isInDst) const = 0;
651 * Checks whether the date and time interpretation is lenient.
655 * @return @c true if the date and time interpretation is set to lenient, @n
658 bool IsLenient(void) const;
661 * Checks whether the specified time field has a value.
665 * @return @c true if the specified time field has a value, @n
667 * @param[in] field The time field
669 bool IsSet(TimeField field) const;
672 * Creates an instance of %Calendar of the specified type with the GMT time zone and the system locale. @n
673 * The time zone is used for the zone offset and the DST offset.
674 * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
675 * The weekdata are set as default values by the locale.
679 * @return A pointer to the created %Calendar instance, @n
680 * else @c null if the method fails
681 * @param[in] calendarType The type of calendar @n
682 * Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
683 * @exception E_SUCCESS The method is successful.
684 * @exception E_OUT_OF_MEMORY The memory is insufficient.
685 * @exception E_SYSTEM A system error has occurred.
686 * @remarks The specific error code can be accessed using the GetLastResult() method.
688 static Calendar* CreateInstanceN(CalendarType calendarType = CALENDAR_GREGORIAN);
691 * Creates an instance of %Calendar of the specified type with the specified time zone and the system locale. @n
692 * The @c timeZone is used for the zone offset and the DST offset.
693 * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
694 * The weekdata are set as default values by the locale.
698 * @return A pointer to the created %Calendar instance, @n
699 * else @c null if the method fails
700 * @param[in] timeZone An instance of TimeZone
701 * @param[in] calendarType The type of calendar @n
702 * Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
703 * @exception E_SUCCESS The method is successful.
704 * @exception E_OUT_OF_MEMORY The memory is insufficient.
705 * @exception E_SYSTEM A system error has occurred.
706 * @remarks The specific error code can be accessed using the GetLastResult() method.
708 static Calendar* CreateInstanceN(const TimeZone& timeZone, CalendarType calendarType = CALENDAR_GREGORIAN);
711 * Creates an instance of %Calendar of the specified type with the specified @c locale and the GMT time zone. @n
712 * The time zone is used for the zone offset and the DST offset.
713 * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
714 * The weekdata are set as default values by the specified @c locale.
717 * @brief <i> [Compatibility] </i>
721 * @compatibility This method has compatibility issues with OSP compatible applications. @n
722 * For more information, see @ref CompCalendarCreateInstanceNPage "here".
725 * @return A pointer to the created %Calendar instance, @n
726 * else @c null if the method fails
727 * @param[in] locale The locale for whose country the %Calendar instance is needed
728 * @param[in] calendarType The type of calendar @n
729 * Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
730 * @exception E_SUCCESS The method is successful.
731 * @exception E_SYSTEM A system error has occurred.
732 * @exception E_OUT_OF_MEMORY The memory is insufficient.
733 * @exception E_INVALID_ARG The specified @c locale is invalid.
734 * @remarks The specific error code can be accessed using the GetLastResult() method.
736 static Calendar* CreateInstanceN(const Locale& locale, CalendarType calendarType = CALENDAR_GREGORIAN);
739 * Creates an instance of %Calendar of the specified type with the specified time zone and @c locale. @n
740 * The @c timeZone is used for the zone offset and the DST offset.
741 * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
742 * The weekdata are set as default values by the specified @c locale.
745 * @brief <i> [Compatibility] </i>
749 * @compatibility This method has compatibility issues with OSP compatible applications. @n
750 * For more information, see @ref CompCalendarCreateInstanceNPage "here".
753 * @return A pointer to the created %Calendar instance, @n
754 * else @c null if the method fails
755 * @param[in] timeZone An instance of TimeZone
756 * @param[in] locale The locale for whose country the %Calendar instance is needed
757 * @param[in] calendarType The type of calendar @n
758 * Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
759 * @exception E_SUCCESS The method is successful.
760 * @exception E_SYSTEM A system error has occurred.
761 * @exception E_OUT_OF_MEMORY The memory is insufficient.
762 * @exception E_INVALID_ARG The specified @c locale is invalid.
763 * @remarks The specific error code can be accessed using the GetLastResult() method.
765 static Calendar* CreateInstanceN(const TimeZone& timeZone, const Locale& locale, CalendarType calendarType = CALENDAR_GREGORIAN);
769 * @page CompCalendarCreateInstanceNPage Compatibility for CreateInstanceN()
770 * @section CompCalendarCreateInstanceNIssueSection Issues
771 * Implementation of this method in OSP compatible applications has the following issue: @n
772 * -# The method returns E_UNSUPPORTED_OPERATION if the locale is invalid.
774 * @section CompCalendarCreateInstanceNSolutionSection Resolutions
775 * This issue has been resolved in Tizen.
776 * @par When working in Tizen:
777 * -# The method returns E_INVALID_ARG if the locale is invalid.
785 * Defines the AM/PM mode. @n
786 * This is a.m./p.m. The indexing is 0-based.
792 AM, /**< The time is in A.M */
793 PM /**< The time is in P.M */
797 * @enum CalendarLimitType
799 * Defines the calendar limitations.
803 enum CalendarLimitType
805 CALENDAR_LIMIT_MINIMUM = 0, /**< The minimum limit */
806 CALENDAR_LIMIT_GREATEST_MINIMUM, /**< The greatest minimum limit */
807 CALENDAR_LIMIT_LEAST_MAXIMUM, /**< The least maximum limit */
808 CALENDAR_LIMIT_MAXIMUM, /**< The maximum limit */
809 CALENDAR_LIMIT_COUNT /**< The number of limit type */
815 * Defines the stamp value.
821 UNSET = 0, /**< Unset */
822 COMPUTED, /**< Computed */
823 MINIMUM_USER_STAMP /**< Minimum user stamp */
827 * This is the default constructor for this class. @n
828 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
837 * Initializes this instance of %Calendar.
841 * @return An error code
842 * @exception E_SUCCESS The method is successful.
844 result Construct(void);
847 * Initializes this instance of %Calendar with the specified parameter.
851 * @return An error code
852 * @param[in] calendar The %Calendar instance to copy
853 * @exception E_SUCCESS The method is successful.
854 * @exception E_SYSTEM A system error has occurred.
857 result Construct(const Calendar& calendar);
860 * Initializes this instance of %Calendar with the specified time zone and @c locale. @n
861 * The @c timeZone is used for the zone offset and the DST offset.
862 * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
863 * The weekdata are set as default values by the specified @c locale.
866 * @brief <i> [Compatibility] </i>
870 * @compatibility This method has compatibility issues with OSP compatible applications. @n
871 * For more information, see @ref CompCalendarConstructPage "here".
874 * @return An error code
875 * @param[in] timeZone An instance of TimeZone
876 * @param[in] locale An instance of Locale
877 * @exception E_SUCCESS The method is successful.
878 * @exception E_INVALID_ARG The specified @c locale is invalid.
880 result Construct(const Tizen::Locales::TimeZone& timeZone, const Locale& locale);
884 * @page CompCalendarConstructPage Compatibility for Construct()
885 * @section CompCalendarConstructIssueSection Issues
886 * Implementation of this method in OSP compatible applications has the following issue: @n
887 * -# The method returns E_UNSUPPORTED_OPERATION if the locale is invalid.
889 * @section CompCalendarConstructSolutionSection Resolutions
890 * This issue has been resolved in Tizen.
891 * @par When working in Tizen:
892 * -# The method returns E_INVALID_ARG if the locale is invalid.
897 * Rolls up or down with a single unit of time on a given time field without changing larger fields. @n
898 * When rolling on the MONTH field, other fields such as DATE field might conflict
899 * and needs to be changed.
903 * @return An error code
904 * @param[in] field The time field to change
905 * @param[in] up Set to @c true if the time field must be rolled upwards, @n
907 * @exception E_SUCCESS The method is successful.
908 * @exception E_INVALID_STATE In this method, the time fields of this instance are calculated. @n
909 * If any time field value previously set is invalid, this exception is returned.
910 * @exception E_INVALID_ARG The specified @c field is invalid (for example, TIME_FIELD_DST_OFFSET, TIME_FIELD_ZONE_OFFSET).
911 * @exception E_OUT_OF_RANGE A time field or its value is out of range. @n
912 * In this method, the time fields of this instance are calculated.
913 * If the value of the time fields goes out of range, this exception is returned.
915 virtual result RollWithSingleUnit(TimeField field, bool up) = 0;
918 * Checks whether the current instance of %Calendar is equivalent to the specified instance of %Calendar.
922 * @return @c true if the current instance of %Calendar is equivalent to the specified %Calendar instance, @n
924 * @param[in] calendar The instance of %Calendar to compare with
925 * @remarks If the specified %Calendar instance is equivalent to the current instance, the two instances behave
926 * exactly the same, but they may be set to different times.
928 virtual bool IsEquivalentTo(const Calendar& calendar) const;
931 * Computes the time field value. @n
932 * Converts the current millisecond time value to TimeField. @n
933 * This allows synching up the time field values with a new time that is set for the calendar.
937 * @return An error code
938 * @exception E_SUCCESS The method is successful.
939 * @exception E_OUT_OF_RANGE The time fields contain an invalid value. @n
940 * In this method, the time fields of this instance are calculated. If the value of the time fields goes out of range, this exception is returned.
942 virtual result ComputeTimeFields(void) = 0;
945 * Computes the time value. @n
946 * Converts the current values of time field to the millisecond time value.
950 * @return An error code
951 * @exception E_SUCCESS The method is successful.
952 * @exception E_INVALID_STATE A value of the internal time field is invalid.
954 virtual result ComputeTime(void) = 0;
957 * Gets the length of the specified month.
961 * @return An integer value indicating the number of days in the specified month
962 * @param[in] extendedYear An extended year
963 * @param[in] month A month
965 virtual int GetMonthLength(int extendedYear, int month) const = 0;
968 * Handles the limits of different types. @n
969 * Derived classes must implement this method for the following fields:
970 * TIME_FIELD_ERA, TIME_FIELD_YEAR, TIME_FIELD_MONTH, TIME_FIELD_WEEK_OF_YEAR, TIME_FIELD_WEEK_OF_MONTH,
971 * TIME_FIELD_DAY_OF_MONTH, TIME_FIELD_DAY_OF_YEAR, TIME_FIELD_DAY_OF_WEEK_IN_MONTH, TIME_FIELD_YEAR_WOY,
972 * TIME_FIELD_EXTENDED_YEAR.
976 * @return The limit of the specified field
977 * @param[in] field The time field
978 * @param[in] limitType The type of limit
980 virtual int HandleGetLimit(TimeField field, CalendarLimitType limitType) const = 0;
983 * Creates and returns a polymorphic copy of this calendar.
987 * @return A polymorphic copy of this calendar
989 virtual Tizen::Locales::Calendar* CloneN(void) const = 0;
992 // This method is for internal use only. Using this method can cause behavioral, security-related,
993 // and consistency-related issues in the application.
995 // This method is reserved and may change its name at any time without prior notice.
999 virtual void Calendar_Reserved1(void) { }
1002 // This method is for internal use only. Using this method can cause behavioral, security-related,
1003 // and consistency-related issues in the application.
1005 // This method is reserved and may change its name at any time without prior notice.
1009 virtual void Calendar_Reserved2(void) { }
1012 // This method is for internal use only. Using this method can cause behavioral, security-related,
1013 // and consistency-related issues in the application.
1015 // This method is reserved and may change its name at any time without prior notice.
1019 virtual void Calendar_Reserved3(void) { }
1022 // This method is for internal use only. Using this method can cause behavioral, security-related,
1023 // and consistency-related issues in the application.
1025 // This method is reserved and may change its name at any time without prior notice.
1029 virtual void Calendar_Reserved4(void) { }
1032 // This method is for internal use only. Using this method can cause behavioral, security-related,
1033 // and consistency-related issues in the application.
1035 // This method is reserved and may change its name at any time without prior notice.
1039 virtual void Calendar_Reserved5(void) { }
1043 * The implementation of this copy constructor is intentionally blank and declared as private to
1044 * prohibit copying of objects. Use CloneN() to get an exact copy of the instance.
1046 Calendar(const Calendar& calendar);
1049 * The implementation of this copy assignment operator is intentionally blank and declared as private
1050 * to prohibit copying of objects. Use CloneN() to get an exact copy of the instance.
1052 Calendar& operator =(const Calendar& calendar);
1056 * Millisecond constants for one day.
1060 static const int ONE_DAY_IN_MILLISEC = 86400000;
1063 * Millisecond constants for one hour.
1067 static const int ONE_HOUR_IN_MILLISEC = 60 * 60 * 1000;
1070 * Millisecond constants for one minute.
1074 static const int ONE_MINUTE_IN_MILLISEC = 60000;
1077 * Millisecond constants for one second.
1081 static const int ONE_SECOND_IN_MILLISEC = 1000;
1084 * Millisecond constants for one week.
1088 static const long long ONE_WEEK_IN_MILLISEC = 7 * ONE_DAY_IN_MILLISEC;
1092 * The field values for the currently set time for this calendar.
1094 int _timeFields[TIME_FIELD_FIELD_COUNT];
1097 * Pseudo-time-stamps which specify when each field is set.
1098 * There are two special values - UNSET and INTERNALLY_SET.
1100 int _stamp[TIME_FIELD_FIELD_COUNT];
1103 * The flags which tell if a specified time field for the calendar is set.
1105 bool _isSet[TIME_FIELD_FIELD_COUNT];
1107 long long _time; // UTC time
1108 Tizen::Locales::TimeZone _timeZone;
1112 bool _areAllFieldsSet;
1115 bool _isConstructed;
1117 // Mask values for calendar fields
1118 static const int ERA_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_ERA);
1119 static const int YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_YEAR);
1120 static const int MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MONTH);
1121 static const int WEEK_OF_YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_WEEK_OF_YEAR);
1122 static const int WEEK_OF_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_WEEK_OF_MONTH);
1123 static const int DAY_OF_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_MONTH);
1124 static const int DAY_OF_YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_YEAR);
1125 static const int DAY_OF_WEEK_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_WEEK);
1126 static const int DAY_OF_WEEK_IN_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_WEEK_IN_MONTH);
1127 static const int AM_PM_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_AM_PM);
1128 static const int HOUR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_HOUR);
1129 static const int HOUR_OF_DAY_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_HOUR_OF_DAY);
1130 static const int MINUTE_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MINUTE);
1131 static const int SECOND_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_SECOND);
1132 static const int MILLISECOND_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MILLISECOND);
1133 static const int ZONE_OFFSET_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_ZONE_OFFSET);
1134 static const int DST_OFFSET_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DST_OFFSET);
1135 static const int ALL_FIELDS = GET_TIME_FIELD_MASK(TIME_FIELD_FIELD_COUNT) - 1;
1138 friend class _CalendarImpl;
1139 class _CalendarImpl* _pCalendarImpl;
1143 }} // Tizen::Locales
1145 #endif //_FLCL_CALENDAR_H_