Move system-server under server/system.
[platform/framework/native/appfw.git] / inc / FLclCalendar.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FLclCalendar.h
19  * @brief               This is the header file for the %Calendar class.
20  *
21  * This header file contains the declarations of the %Calendar class.
22  *
23  */
24 #ifndef _FLCL_CALENDAR_H_
25 #define _FLCL_CALENDAR_H_
26
27 #include <FBase.h>
28 #include <FLclLocale.h>
29 #include <FLclTimeZone.h>
30
31 namespace Tizen { namespace Locales
32 {
33 /**
34  * @class               Calendar
35  * @brief               This class provides methods for displaying a calendar.
36  *
37  * @since               2.0
38  *
39  * 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.
40  * Subclasses of %Calendar interpret %Tizen::Base::DateTime according to the rules of a specific calendar system. GregorianCalendar is commonly used.
41  *
42  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/locales/calendar.htm">Calendar</a>.
43  *
44  * @see                 Tizen::Locales::TimeZone
45  *
46  * The following example demonstrates how to use the %Calendar class to set or add the time field.
47  *
48  @code
49  *
50  #include <FBase.h>
51  #include <FLocales.h>
52
53  using namespace Tizen::Base;
54  using namespace Tizen::Locales;
55
56  void
57  MyClass::CalendarExample(void)
58  {
59         int offset = 60;
60         String timeZoneName(L"Europe/Paris");
61         TimeZone timeZone(offset, timeZoneName);
62
63         Calendar* pCalendar = Calendar::CreateInstanceN(timeZone, CALENDAR_GREGORIAN);
64         pCalendar->SetTime(2012,7,18);
65
66         // Increase one day. The date will be 2012/7/19
67         pCalendar->AddTimeField(TIME_FIELD_DAY_OF_MONTH, 1);
68
69         // Decrease two months. The date will be 2012/5/19
70         pCalendar->AddTimeField(TIME_FIELD_MONTH, -2);
71
72         delete pCalendar;
73  }
74  @endcode
75  */
76 #define GET_TIME_FIELD_MASK(X)  (static_cast<int>(1 << (X)))
77 /**
78 * @enum TimeField
79 *
80 * Defines the time fields for date and time. @n
81 * This enum is used in %Calendar.
82 *
83 * @since                2.0
84 */
85 enum TimeField
86 {
87         TIME_FIELD_ERA,                                                 /**< Era : 0 - BC, 1 - AD */
88         TIME_FIELD_YEAR,                                                /**< Year : 1-based */
89         TIME_FIELD_MONTH,                                               /**< Month : 1-based (1~13)*/
90         TIME_FIELD_WEEK_OF_YEAR,                                /**< Week of Year : 1-based (1~53) */
91         TIME_FIELD_WEEK_OF_MONTH,                               /**< Week of Month : 1-based (1~6, may be specified as 0) */
92         TIME_FIELD_DAY_OF_MONTH,                                /**< Date : 1-based (1~31) */
93         TIME_FIELD_DAY_OF_YEAR,                                 /**< Day of Year : 1-based (1~366) */
94         TIME_FIELD_DAY_OF_WEEK,                                 /**< Day of Week : 1-based (1~7) */
95         TIME_FIELD_DAY_OF_WEEK_IN_MONTH,                /**< Day of Week in Month : 1-based (1~5, may be specified as -1) */
96         TIME_FIELD_AM_PM,                                               /**< AmPm : 0 - AM, 1 - PM */
97         TIME_FIELD_HOUR,                                                /**< Hour : 0-based (0~11) */
98         TIME_FIELD_HOUR_OF_DAY,                                 /**< Hour of Day : 0-based (0~23) */
99         TIME_FIELD_MINUTE,                                              /**< Minute : 0-based (0~59) */
100         TIME_FIELD_SECOND,                                              /**< Second : 0-based (0~59) */
101         TIME_FIELD_MILLISECOND,                                 /**< Millisecond : 0-based (0~999) */
102         TIME_FIELD_ZONE_OFFSET,                                 /**< Time Zone Offset : 0-based (-43200000~54000000 in milliseconds) */ 
103         TIME_FIELD_DST_OFFSET,                                  /**< Daylight Saving Offset : 0-based (0~3600000 in milliseconds)*/
104         TIME_FIELD_FIELD_COUNT                                  /**< The number of time field */
105 };
106
107 class _OSP_EXPORT_ Calendar
108         : public Tizen::Base::Object
109 {
110 public:
111         /**
112          * This is the destructor for this class. @n 
113          * This destructor overrides Tizen::Base::Object::~Object().
114          *
115          * @since               2.0
116          */
117         virtual ~Calendar(void);
118
119         /**
120         * Adds the specified amount to the given time field, based on the calendar rules. @n
121         * It is equivalent to calling SetTimeField(field, GetTimeField(field)+amount) with two adjustments. @n
122         *
123         * @b Add @b Rule1: The value of the time field @c field after the call minus the value of the field
124         * before the call is delta modulo any overflow that has occurred in the field.
125         * Overflow occurs when a time field value exceeds its range and, as a result, the next larger field
126         * is incremented or decremented and the field value is adjusted back into its range. @n
127         *
128         * @b Add @b Rule2: If a smaller field is expected to be invariant, but it is impossible for it to be
129         * equal to its prior value because of changes in its minimum or maximum value after the time field @c field
130         * is changed, then its value is adjusted to be as close as possible to its expected value. @n
131         *
132         * A smaller field represents a smaller unit of time. TIME_FIELD_HOUR is a smaller field than TIME_FIELD_DAY_OF_MONTH.
133         * No adjustment is made to smaller fields that are not expected to be invariant.
134         * The calendar system determines what fields are expected to be invariant.
135         *
136         * In addition, this method forces re-computation of the calendar's milliseconds and
137         * all time fields immediately. @n
138         *
139         * For example, consider a GregorianCalendar set to Oct 31, 2004.
140         * Calling AddTimeField(TIME_FIELD_MONTH, 13) sets the calendar to Nov 30, 2005. @n
141         * The TIME_FIELD_MONTH field is set to NOVEMBER by @b Rule1, since adding 13 months to October gives the
142         * November of the next year.
143         * 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.
144         *
145         * @if OSPCOMPAT
146         * @brief <i> [Compatibility] </i>
147         * @endif
148         * @since                        2.0
149         * @if OSPCOMPAT
150         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
151         *                              For more information, see @ref CompCalendarAddTimeFieldPage "here".
152         * @endif
153         *
154         * @return                       An error code
155         * @param[in]            field                                           The time field
156         * @param[in]            amount                                          The amount to add
157         * @exception            E_SUCCESS                                       The method is successful.
158         * @exception            E_INVALID_ARG                                  The specified @c field is invalid.  
159         */
160         virtual result AddTimeField(TimeField field, int amount) = 0;
161
162         /**
163         * @if OSPCOMPAT
164         * @page                    CompCalendarAddTimeFieldPage Compatibility for AddTimeField()
165         * @section                   CompCalendarAddTimeFieldIssueSection Issues
166         * Implementation of this method in OSP compatible applications has the following issue: @n
167         * -# The method returns E_INVALID_STATE if the time field is invalid.
168         *
169         * @section                 CompCalendarAddTimeFieldSolutionSection Resolutions
170         * This issue has been resolved in Tizen.
171         *
172         * @par When working in Tizen:
173         * -# The method returns E_INVALID_ARG if the time field is invalid.
174         * @endif
175         */
176
177         /**
178         * Compares the current instance of %Calendar with the specified instance.
179         *
180         * @if OSPCOMPAT
181         * @brief <i> [Compatibility] </i>
182         * @endif
183         * @since                                2.0
184         * @if OSPCOMPAT
185         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
186         *                              For more information, see @ref CompCalendarAfterPage "here".
187         * @endif
188         *
189         * @return                               An error code
190         * @param[in]            otherCalendar                                   The instance of %Calendar to compare
191         * @param[out]           after                                           Set to @c true if the current instance of %Calendar is after the specified instance of %Calendar, @n
192         *                                                                               else @c false
193         * @exception            E_SUCCESS                                       The method is successful.
194         * @exception            E_INVALID_ARG                                   The specified @c otherCalendar is invalid. 
195         * @exception            E_INVALID_STATE                                 In this method, the time fields of this instance are calculated. @n 
196         *                                                                               If any time field value previously set is invalid, this exception is returned. 
197         * @exception            E_OUT_OF_RANGE                                  In this method, the time fields of this instance are calculated. @n
198         *                                                                                If the value of the time fields goes out of range, this exception is returned. 
199         */
200         result After(const Calendar& otherCalendar, bool& after);
201
202         /**
203         * @if OSPCOMPAT
204         * @page                    CompCalendarAfterPage Compatibility for After()
205         * @section                   CompCalendarAfterIssueSection Issues
206         * Implementation of this method in OSP compatible applications has the following issue: @n
207         * -# The method returns E_INVALID_STATE and E_OUT_OF_RANGE if the instance of %Calendar to be compared is invalid.
208         *
209         * @section                 CompCalendarAfterSolutionSection Resolutions
210         * This issue has been resolved in Tizen.
211         *
212         * @par When working in Tizen: 
213         * -# The method returns E_INVALID_ARG if the instance of %Calendar to be compared is invalid.
214         * -# The method returns E_INVALID_STATE if any time field value previously set is invalid.
215         * -# The method returns E_OUT_OF_RANGE if the value of the time fields goes out of range.
216         * @endif
217         */                                        
218
219         /**
220         * Compares the current instance of %Calendar with the specified instance.
221         *
222         * @if OSPCOMPAT
223         * @brief <i> [Compatibility] </i>
224         * @endif
225         * @since                                2.0
226         * @if OSPCOMPAT
227         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
228         *                              For more information, see @ref CompCalendarBeforePage "here".
229         * @endif
230         *
231         * @return                               An error code
232         * @param[in]                    otherCalendar                           The instance of %Calendar to compare
233         * @param[out]                   before                                  Set to @c true if the current instance of %Calendar is before the specified instance of %Calendar, @n
234         *                                                                               else @c false
235         * @exception            E_SUCCESS                               The method is successful.
236         * @exception            E_INVALID_ARG                           The specified @c otherCalendar is invalid. 
237         * @exception            E_INVALID_STATE                         In this method, the time fields of this instance are calculated. @n
238         *                                                                        If any time field value previously set is invalid, this exception is returned. 
239         * @exception            E_OUT_OF_RANGE                          In this method, the time fields of this instance are calculated. @n
240         *                                                                        If the value of the time fields goes out of range, this exception is returned. 
241         */
242         result Before(const Calendar& otherCalendar, bool& before);
243
244         /**
245         * @if OSPCOMPAT
246         * @page                    CompCalendarBeforePage Compatibility for Before()
247         * @section                   CompCalendarBeforeIssueSection Issues
248         * Implementation of this method in OSP compatible applications has the following issue: @n
249         * -# The method returns E_INVALID_STATE and E_OUT_OF_RANGE if the instance of %Calendar to be compared is invalid.
250         *
251         * @section                 CompCalendarBeforeSolutionSection Resolutions
252         * This issue has been resolved in Tizen.
253         *
254         * @par When working in Tizen: 
255         * -# The method returns E_INVALID_ARG if the instance of %Calendar to be compared is invalid.
256         * -# The method returns E_INVALID_STATE if any time field value previously set is invalid.
257         * -# The method returns E_OUT_OF_RANGE if the value of the time fields goes out of range.
258         * @endif
259         */
260
261         /**
262         * Clears all the time fields and sets it to @c 0. @n
263         * Zero is not the default value for each field. It means the field is cleared.
264         *
265         * @since                                2.0
266         *
267         * @return                               An error code
268         * @exception                    E_SUCCESS                                       The method is successful.
269         */
270         result Clear(void);
271
272         /**
273         * Clears the specified time field and sets it to @c 0. @n
274         * Zero is not the default value for each field. It means the field is cleared.
275         *
276         * @since                                2.0
277         *
278         * @return                               An error code
279         * @param[in]                    field                                           The time field to clear
280         * @exception                    E_SUCCESS                                       The method is successful.
281         */
282         result Clear(TimeField field);
283
284         /**
285         * Checks whether the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Calendar.
286         *
287         * @since                        2.0
288         *
289         * @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
290         *                                       else @c false
291         * @param[in]            obj An instance of Tizen::Base::Object to compare
292         */
293         virtual bool Equals(const Tizen::Base::Object& obj) const;
294
295         /**
296         * Gets the hash value of the current instance.
297         *
298         * @since                        2.0
299         *
300         * @return                       The hash value of the current instance
301         */
302         virtual int GetHashCode(void) const;
303
304         /**
305         * 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
306         * If the specified @c amount is negative, the amount value is deducted from the specified time field value.
307         * 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.
308         *
309         * @if OSPCOMPAT
310         * @brief <i> [Compatibility] </i>
311         * @endif
312         * @since                                2.0
313         * @if OSPCOMPAT
314         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
315         *                              For more information, see @ref CompCalendarRollPage "here".
316         * @endif
317         *
318         * @return                               An error code
319         * @param[in]                    field                                                   The time field to roll
320         * @param[in]                    amount                                                  The amount to add to the time field
321         * @exception                    E_SUCCESS                                               The method is successful.
322         * @exception                    E_INVALID_ARG                                   The specified @c field is invalid (for example, TIME_FIELD_DST_OFFSET, TIME_FIELD_ZONE_OFFSET). 
323         * @exception            E_OUT_OF_RANGE                          In this method, the time fields of this instance are calculated. @n
324         *                                                                        If the value of the time fields goes out of range, this exception is returned.
325         */
326         virtual result Roll(TimeField field, int amount);
327
328         /**
329         * @if OSPCOMPAT
330         * @page                    CompCalendarRollPage Compatibility for Roll()
331         * @section                   CompCalendarRollIssueSection Issues
332         * Implementation of this method in OSP compatible applications has the following issue: @n
333         * -# The method returns E_INVALID_STATE if the time field is invalid.
334         *
335         * @section                 CompCalendarRollSolutionSection Resolutions
336         * This issue has been resolved in Tizen.
337         *
338         * @par When working in Tizen: 
339         * -# The method returns E_INVALID_ARG if the time field is invalid.
340         * @endif
341         */
342
343         /**
344         * Sets the specified time field with the specified @c value. @n
345         * This sets an internal member variable to indicate that the field has been changed.
346         * Although the time field is changed, the milliseconds of %Calendar are not recomputed
347         * until GetTimeField(), GetTime(), or GetTimeInMillisec() is called.
348         * Thus, even if you call this method several times, unnecessary multiple computations are not triggered. @n
349         *
350         * As a result of changing a field using SetTimeField(), other fields may also change
351         * depending on the field, the field value, and the calendar system. @n
352         *
353         * For example, consider a GregorianCalendar set to Oct. 31, 2004.
354         * Calling SetTimeField(TIME_FIELD_MONTH, NOVEMBER) sets the calendar to Nov 31, 2004. @n
355         * But, if you call GetTime(), then Dec 1, 2004 is returned because Nov 31, 2004 does not exist.
356         * However, a call to SetTimeField(TIME_FIELD_MONTH, SEPTEMBER) before a call to GetTime() sets the calendar
357         * to Sep 30, 2004, since no re-computation has occurred after the first call to SetTimeField().
358         *
359         * The value of field is not affected by it being local time or UTC time.
360         * The value is only overwritten.
361         *
362         * @since                                2.0
363         *
364         * @return                               An error code
365         * @param[in]                    field                                   The time field to set
366         * @param[in]                    value                                   The value to set
367         * @exception                    E_SUCCESS                               The method is successful.
368         * @exception                    E_OUT_OF_RANGE                  The value is out of range in lenient mode.
369         * @exception                    E_INVALID_ARG                   The specified @c field is invalid.
370         */
371         result SetTimeField(TimeField field, int value);
372
373         /**
374         * Sets the first day of the week.
375         *
376         * @since                                2.0
377         *
378         * @return                               An error code
379         * @param[in]                    dayOfWeek                               The value to set as the first day of the week
380         * @exception                    E_SUCCESS                               The method is successful.
381         * @exception                    E_INVALID_ARG                   The specified @c dayOfWeek is invalid.
382         */
383         result SetFirstDayOfWeek(DayOfWeek dayOfWeek);
384
385         /**
386         * Sets the leniency of date and time interpretations.
387         *
388         * @since                                2.0
389         *
390         * @return                               An error code
391         * @param[in]                    lenient                                 Set to @c true if the date and time interpretation is set to lenient, @n
392         *                                                                                               else @c false
393         * @exception                    E_SUCCESS                               The method is successful.
394         */
395         result SetLenient(bool lenient);
396
397         /**
398         * Sets the minimal days required in the first week.
399         *
400         * @since                                2.0
401         *
402         * @return                               An error code
403         * @param[in]                    value                                   The minimal days required in the first week
404         * @exception                    E_SUCCESS                               The method is successful.
405         */
406         result SetMinDaysInFirstWeek(short value);
407
408         /**
409         * Sets the value of year, month, day, hour, minute, and seconds. @n
410         * The date and time are local time.
411         *
412         * @since                                2.0
413         *
414         * @return                               An error code
415         * @param[in]                    year                                    The value to set for year
416         * @param[in]                    month                                   The value to set for month @n
417         *                                                                                               The indexing is 1-based. Therefore, 1 means January.
418         * @param[in]                    day                                             The value to set for day
419         * @param[in]                    hour                                    The value to set for hour
420         * @param[in]                    minute                                  The value to set for minute
421         * @param[in]                    second                                  The value to set for second
422         * @exception                    E_SUCCESS                               The method is successful.
423         * @exception                    E_OUT_OF_RANGE                   A time field or its value is out of range in lenient mode.
424         */
425         result SetTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0);
426
427         /**
428         * Sets the calendar's current time with the specified Tizen::Base::DateTime.
429         *
430         * @since                                2.0
431         *
432         * @return                               An error code
433         * @param[in]                    dateTime                                The Tizen::Base::DateTime instance to set
434         * @exception                    E_SUCCESS                               The method is successful.
435         * @remarks                              The time specified is the local time.
436         */
437         result SetTime(const Tizen::Base::DateTime& dateTime);
438
439         /**
440         * Sets the current time of this %Calendar instance with the specified value.
441         *
442         * @since                                2.0
443         *
444         * @return                               An error code
445         * @param[in]                    millisec                                The new time in milliseconds from the starting day (Jan 1, 1.)
446         * @exception                    E_SUCCESS                               The method is successful.
447         * @exception                    E_OUT_OF_RANGE                  A time field or its value is out of range.
448         */
449         result SetTimeInMillisec(long long millisec);
450
451         /**
452         * Sets the time zone of the calendar to the specified time zone.
453         *
454         * @since                        2.0
455         *
456         * @return                       An error code
457         * @param[in]            timeZone                                The time zone to set
458         * @exception            E_SUCCESS                               The method is successful.
459         */
460         result SetTimeZone(const TimeZone& timeZone);
461
462         /**
463          * Gets the actual maximum value that the specified field can have, given the current date. @n
464          * For example, if the current date is "Feb 10, 2004" and the time field specified is TIME_FIELD_DAY_OF_MONTH, then the actual
465          * maximum value for this time field is 29.
466          *
467          * @since                                       2.0
468          *
469          * @return                                      An integer value indicating the actual maximum value
470          * @param[in]                           field           The time field
471          * @exception                           E_SUCCESS                       The method is successful.
472          * @exception                           E_INVALID_ARG                   The specified @c field is invalid.
473          * @remarks                                     The specific error code can be accessed using the GetLastResult() method.
474          */
475         virtual int GetActualMaxTimeField(TimeField field) const;
476
477         /**
478          * Gets the actual minimum value that the specified time field can have, given the current date. @n
479          * For the Gregorian calendar, this is the same as GetMinTimeField() and
480          * GetGreatestMinTimeField().
481          *
482          * @since                                       2.0
483          *
484          * @return                                      An integer value indicating the actual minimum value 
485          * @param[in]                           field           The time field
486          * @exception                           E_SUCCESS                       The method is successful.
487          * @exception                           E_INVALID_ARG                   The specified @c field is invalid.
488          * @exception                           E_SYSTEM                        A system error has occurred.
489          * @remarks                                     The specific error code can be accessed using the GetLastResult() method.
490          */
491         virtual int GetActualMinTimeField(TimeField field) const;
492
493         /**
494         * Gets the value of the first day of the week. @n
495         * For example, in USA, the first day of the week is SUNDAY. But, it is MONDAY in France.
496         *
497         * @since                                        2.0
498         *
499         * @return                                       An integer value indicating the first day of the week, @n
500         *                                               else @c -1 if the method fails
501         */
502         int GetFirstDayOfWeek(void) const;
503
504         /**
505         * Gets the greatest minimum value that the specified time field can have.
506         *
507         * @since                                        2.0
508         *
509         * @return                                       An integer value indicating the greatest minimum value for the specified time field
510         * @param[in]                            field           The time field
511         * @exception                            E_SUCCESS                       The method is successful.
512         * @exception                            E_INVALID_ARG                   The specified @c field is invalid.
513         * @exception                            E_SYSTEM                        A system error has occurred.
514         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
515         */
516         virtual int GetGreatestMinTimeField(TimeField field) const;
517
518         /**
519         * Gets the least maximum value that the specified time field can have.
520         *
521         * @since                                        2.0
522         *
523         * @return                                       An integer value indicating the least maximum value for the specified time field
524         * @param[in]                            field           The time field
525         * @exception                            E_SUCCESS                       The method is successful.
526         * @exception                            E_INVALID_ARG                   The specified @c field is invalid.
527         * @exception                            E_SYSTEM                        A system error has occurred.
528         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
529         */
530         virtual int GetLeastMaxTimeField(TimeField field) const;
531
532         /**
533         * Gets the maximum value that the specified time field can have.
534         *
535         * @since                                        2.0
536         *
537         * @return                                       An integer value indicating the maximum value for the specified time field
538         * @param[in]                            field           The time field
539         * @exception                            E_SUCCESS                       The method is successful.
540         * @exception                            E_INVALID_ARG                   The specified @c field is invalid.
541         * @exception                            E_SYSTEM                        A system error has occurred.
542         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
543         */
544         virtual int GetMaxTimeField(TimeField field) const;
545
546         /**
547         * Gets the minimum value that the specified time field can have.
548         *
549         * @since                                        2.0
550         *
551         * @return                                       An integer value indicating the minimum value for the specified time field
552         * @param[in]                            field           The time field
553         * @exception                            E_SUCCESS                       The method is successful.
554         * @exception                            E_INVALID_ARG                   The specified @c field is invalid.
555         * @exception                            E_SYSTEM                        A system error has occurred.
556         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
557         */
558         virtual int GetMinTimeField(TimeField field) const;
559
560         /**
561         * Gets the minimum number of days required in the first week of the year. @n
562         * For example, if the first week is defined as the one that contains the first day of
563         * the first month of a year, this method returns @c 1.
564         *
565         * @since                                        2.0
566         *
567         * @return                                       An integer value indicating the minimum number of days required in the first week
568         */
569         int GetMinDaysInFirstWeek(void) const;
570
571         /**
572         * Gets the date and time of the current instance of %Calendar.
573         *
574         * @since                                        2.0
575         *
576         * @return                                       An instance of Tizen::Base::DateTime with the current time in local time
577         * @remarks                                      The time specified is local time.
578         */
579         Tizen::Base::DateTime GetTime(void) const;
580
581         /**
582         * Gets the value of the specified time field.
583         *
584         * @since                                        2.0
585         *
586         * @return                                       An integer value indicating the value of the specified time field
587         *                                                       
588         * @param[in]                            field           The given time field
589         * @exception                            E_SUCCESS                       The method is successful.
590         * @exception                            E_INVALID_ARG                   The specified @c field is invalid.
591         * @exception                            E_SYSTEM                        A system error has occurred.
592         * @remarks                                      This method is semantically const, but may alter the instance in memory.
593         *                                               All fields are re-computed if any field is invalid.
594         *                                               The specific error code can be accessed using the GetLastResult() method.
595         */
596         int GetTimeField(TimeField field) const;
597
598         /**
599         * Gets the current time of the instance in the @c long format.
600         *
601         * @since                                        2.0
602         *
603         * @return                                       An error code
604         * @param[out]                           millisec                                                The current time in milliseconds from starting day (Jan 1, 1.)
605         * @exception                            E_SUCCESS                                               The method is successful.
606         * @exception                            E_INVALID_STATE                                 In this method, the time fields of this instance are calculated. @n
607         *                                                                                                If any time field value previously set is invalid, this exception is returned.
608         * @exception                            E_OUT_OF_RANGE                                  The value of the argument is out of the valid range defined by the method.
609         */
610         result GetTimeInMillisec(long long& millisec) const;
611
612         /**
613         * Gets a reference to the time zone owned by this instance of %Calendar.
614         *
615         * @since                                        2.0
616         *
617         * @return                                       The TimeZone instance associated with the current instance of %Calendar
618         * @remarks                                      The returned reference is valid only until the SetTimeZone() method is called or this instance of %Calendar is destroyed.
619         * @see                                          SetTimeZone()
620         */
621         TimeZone GetTimeZone(void) const;
622
623         /**
624         * Gets the calendar type of the current instance of %Calendar.
625         *
626         * @since                                        2.0
627         *
628         * @return                                       An instance of CalendarType representing the calendar type of the current instance of %Calendar @n
629         *                                                       For example, CALENDAR_GREGORIAN.
630         */
631         virtual CalendarType GetType(void) const = 0;
632
633         /**
634         * Checks whether the current date for the instance of %Calendar is in Daylight Saving Time (DST).
635         *
636         * @since                                        2.0
637         *
638         * @return                                       An error code
639         * @param[out]                           isInDst                 Set to @c true if the current date is in DST, @n
640         *                                                                                       else @c false
641         * @exception                            E_SUCCESS                                               The method is successful.
642         * @exception                            E_INVALID_STATE         In this method, the time fields of this instance are calculated. @n 
643         *                                                                       If any time field value previously set is invalid, this exception is returned.
644         * @exception                            E_OUT_OF_RANGE                                  A time field or its value is out of range. @n
645         *                                       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.
646         */
647         virtual result IsInDst(bool& isInDst) const = 0;
648
649         /**
650         * Checks whether the date and time interpretation is lenient.
651         *
652         * @since                                        2.0
653         *
654         * @return                                       @c true if the date and time interpretation is set to lenient, @n
655         *                                                       else @c false
656         */
657         bool IsLenient(void) const;
658
659         /**
660         * Checks whether the specified time field has a value.
661         *
662         * @since                                        2.0
663         *
664         * @return                                       @c true if the specified time field has a value, @n
665         *                                                       else @c false
666         * @param[in]                            field           The time field
667         */
668         bool IsSet(TimeField field) const;
669
670         /**
671         * Creates an instance of %Calendar of the specified type with the GMT time zone and the system locale. @n
672         * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
673         * The weekdata are set as default values by the locale.
674         *
675         * @since                                        2.0
676         *
677         * @return                                       A pointer to the created %Calendar instance, @n
678         *                                                       else @c null if the method fails
679         * @param[in]                            calendarType            The type of calendar @n
680         *                                                                               Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
681         * @exception                            E_SUCCESS                       The method is successful.
682         * @exception                            E_OUT_OF_MEMORY         The memory is insufficient.
683         * @exception                            E_SYSTEM                        A system error has occurred.
684         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
685         */
686         static Calendar* CreateInstanceN(CalendarType calendarType = CALENDAR_GREGORIAN);
687
688         /**
689         * Creates an instance of %Calendar of the specified type with the specified time zone and the system locale. @n
690         * The @c timeZone is used for the zone offset and the DST offset.
691         * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
692         * The weekdata are set as default values by the locale.
693         *
694         * @since                                        2.0
695         *
696         * @return                                       A pointer to the created %Calendar instance, @n
697         *                                                       else @c null if the method fails
698         * @param[in]                            timeZone                        An instance of TimeZone
699         * @param[in]                            calendarType            The type of calendar @n
700         *                                                                               Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
701         * @exception                            E_SUCCESS                       The method is successful.
702         * @exception                            E_OUT_OF_MEMORY         The memory is insufficient.
703         * @exception                            E_SYSTEM                        A system error has occurred.
704         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
705         */
706         static Calendar* CreateInstanceN(const TimeZone& timeZone, CalendarType calendarType = CALENDAR_GREGORIAN);
707
708         /**
709         * Creates an instance of %Calendar of the specified type with the specified @c locale and the GMT time zone. @n
710         * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
711         * The weekdata are set as default values by the specified @c locale.
712         *
713         * @if OSPCOMPAT
714         * @brief <i> [Compatibility] </i>
715         * @endif
716         * @since                                        2.0
717         * @if OSPCOMPAT
718         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
719         *                              For more information, see @ref CompCalendarCreateInstanceNPage "here".
720         * @endif
721         *
722         * @return                                       A pointer to the created %Calendar instance, @n
723         *                                                       else @c null if the method fails
724         * @param[in]                            locale                          The locale for whose country the %Calendar instance is needed
725         * @param[in]                            calendarType            The type of calendar @n
726         *                                                                               Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
727         * @exception                            E_SUCCESS                       The method is successful.
728         * @exception                            E_SYSTEM                        A system error has occurred.
729         * @exception                            E_OUT_OF_MEMORY                         The memory is insufficient.
730         * @exception                            E_INVALID_ARG           The specified @c locale is invalid. 
731         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
732         */
733         static Calendar* CreateInstanceN(const Locale& locale, CalendarType calendarType = CALENDAR_GREGORIAN);
734
735         /**
736         * Creates an instance of %Calendar of the specified type with the specified time zone and @c locale. @n
737         * The @c timeZone is used for the zone offset and the DST offset.
738         * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
739         * The weekdata are set as default values by the specified @c locale.
740         *
741         * @if OSPCOMPAT
742         * @brief <i> [Compatibility] </i>
743         * @endif
744         * @since                                        2.0
745         * @if OSPCOMPAT
746         * @compatibility     This method has compatibility issues with OSP compatible applications. @n
747         *                              For more information, see @ref CompCalendarCreateInstanceNPage "here".
748         * @endif        
749         *
750         * @return                                       A pointer to the created %Calendar instance, @n
751         *                                                       else @c null if the method fails
752         * @param[in]                            timeZone                        An instance of TimeZone
753         * @param[in]                            locale                          The locale for whose country the %Calendar instance is needed
754         * @param[in]                            calendarType            The type of calendar @n
755         *                                                                               Default calendar is the Gregorian calendar (CALENDAR_GREGORIAN).
756         * @exception                            E_SUCCESS                       The method is successful.
757         * @exception                            E_SYSTEM                        A system error has occurred.
758         * @exception                            E_OUT_OF_MEMORY                         The memory is insufficient.
759         * @exception                            E_INVALID_ARG           The specified @c locale is invalid. 
760         * @remarks                                      The specific error code can be accessed using the GetLastResult() method.
761         */
762         static Calendar* CreateInstanceN(const TimeZone& timeZone, const Locale& locale, CalendarType calendarType = CALENDAR_GREGORIAN);
763
764         /**
765         * @if OSPCOMPAT
766         * @page                    CompCalendarCreateInstanceNPage Compatibility for CreateInstanceN()
767         * @section                   CompCalendarCreateInstanceNIssueSection Issues
768         * Implementation of this method in OSP compatible applications has the following issue: @n
769         * -# The method returns E_UNSUPPORTED_OPERATION if the locale is invalid.
770         *
771         * @section                 CompCalendarCreateInstanceNSolutionSection Resolutions
772         * This issue has been resolved in Tizen.
773         * @par When working in Tizen: 
774         * -# The method returns E_INVALID_ARG if the locale is invalid.
775         * @endif
776         */
777
778 protected:
779         /**
780         * @enum AmPm
781         *
782         * Defines the AM/PM mode. @n
783         * This is a.m./p.m. The indexing is 0-based.
784         *
785         * @since                                        2.0
786         */
787         enum AmPm
788         {
789                 AM, /**< The time is in A.M */
790                 PM  /**< The time is in P.M */
791         };
792
793         /**
794         * @enum CalendarLimitType
795         *
796         * Defines the calendar limitations.
797         *
798         * @since                                        2.0
799         */
800         enum CalendarLimitType
801         {
802                 CALENDAR_LIMIT_MINIMUM = 0,             /**< The minimum limit */
803                 CALENDAR_LIMIT_GREATEST_MINIMUM,        /**< The greatest minimum limit */
804                 CALENDAR_LIMIT_LEAST_MAXIMUM,           /**< The least maximum limit */
805                 CALENDAR_LIMIT_MAXIMUM,                 /**< The maximum limit */
806                 CALENDAR_LIMIT_COUNT                    /**< The number of limit type */
807         };
808
809         /**
810         * @enum StampValue
811         *
812         * Defines the stamp value.
813         *
814         * @since                                        2.0
815         */
816         enum StampValue
817         {
818                 UNSET = 0,              /**< Unset */
819                 COMPUTED,               /**< Computed */
820                 MINIMUM_USER_STAMP      /**< Minimum user stamp */
821         };
822
823         /**
824          * This is the default constructor for this class. @n
825          * 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.
826          *
827          * @since                                       2.0
828          *
829          * @see                                         Construct()
830          */
831         Calendar(void);
832
833         /**
834          * Initializes this instance of %Calendar.
835          *
836          * @since                                       2.0
837          *
838          * @return                                      An error code
839          * @exception                           E_SUCCESS                                       The method is successful.
840          */
841         result Construct(void);
842
843         /**
844          * Initializes this instance of %Calendar with the specified parameter.
845          *
846          * @since                                       2.0
847          *
848          * @return                                      An error code
849          * @param[in]                           calendar                                        The %Calendar instance to copy
850          * @exception                           E_SUCCESS                                       The method is successful.
851          * @exception                           E_SYSTEM                                        A system error has occurred.
852          *
853          */
854         result Construct(const Calendar& calendar);
855
856         /**
857          * Initializes this instance of %Calendar with the specified time zone and @c locale. @n
858          * The @c timeZone is used for the zone offset and the DST offset.
859          * An instance has weekdata which are the first of week, minimal days in the first week, weekend on set, and weekend cease.
860          * The weekdata are set as default values by the specified @c locale.
861          *
862          * @if OSPCOMPAT
863          * @brief <i> [Compatibility] </i>
864          * @endif
865          * @since                                       2.0
866          * @if OSPCOMPAT
867          * @compatibility     This method has compatibility issues with OSP compatible applications. @n
868          *                              For more information, see @ref CompCalendarConstructPage "here".       
869          * @endif
870          *
871          * @return                                      An error code
872          * @param[in]                           timeZone                                        An instance of TimeZone
873          * @param[in]                           locale                                          An instance of Locale
874          * @exception                           E_SUCCESS                                       The method is successful.
875          * @exception                            E_INVALID_ARG           The specified @c locale is invalid. 
876          */
877         result Construct(const Tizen::Locales::TimeZone& timeZone, const Locale& locale);
878
879         /**
880          * @if OSPCOMPAT
881          * @page                    CompCalendarConstructPage Compatibility for Construct()
882          * @section                   CompCalendarConstructIssueSection Issues
883          * Implementation of this method in OSP compatible applications has the following issue: @n
884          * -# The method returns E_UNSUPPORTED_OPERATION if the locale is invalid.
885          *
886          * @section                 CompCalendarConstructSolutionSection Resolutions
887          * This issue has been resolved in Tizen.
888          * @par When working in Tizen: 
889          * -# The method returns E_INVALID_ARG if the locale is invalid.
890          * @endif        
891          */
892
893         /**
894         * Rolls up or down with a single unit of time on a given time field without changing larger fields. @n
895         * When rolling on the MONTH field, other fields such as DATE field might conflict
896         * and needs to be changed.
897         *
898         * @since                                        2.0
899         *
900         * @return                                       An error code
901         * @param[in]                            field                                                   The time field to change
902         * @param[in]                            up                                                              Set to @c true if the time field must be rolled upwards, @n
903         *                                                                                                                       else @c false
904         * @exception                            E_SUCCESS                                               The method is successful.
905         * @exception                            E_INVALID_STATE                                 In this method, the time fields of this instance are calculated. @n 
906         *                                                                                               If any time field value previously set is invalid, this exception is returned.
907         * @exception                            E_INVALID_ARG                                   The specified @c field is invalid (for example, TIME_FIELD_DST_OFFSET, TIME_FIELD_ZONE_OFFSET).
908         * @exception                            E_OUT_OF_RANGE           A time field or its value is out of range. @n
909         *                                                       In this method, the time fields of this instance are calculated.
910         *                                                       If the value of the time fields goes out of range, this exception is returned.
911         */
912         virtual result RollWithSingleUnit(TimeField field, bool up) = 0;
913
914         /**
915          * Checks whether the current instance of %Calendar is equivalent to the specified instance of %Calendar.
916          *
917          * @since                                       2.0
918          *
919          * @return                                      @c true if the current instance of %Calendar is equivalent to the specified %Calendar instance, @n
920          *                                                      else @c false
921          * @param[in]                           calendar                The instance of %Calendar to compare with
922          * @remarks                                     If the specified %Calendar instance is equivalent to the current instance, the two instances behave
923          *                                                      exactly the same, but they may be set to different times.
924          */
925         virtual bool IsEquivalentTo(const Calendar& calendar) const;
926
927         /**
928         * Computes the time field value. @n
929         * Converts the current millisecond time value to TimeField. @n
930         * This allows synching up the time field values with a new time that is set for the calendar.
931         *
932         * @since                                                2.0
933         *
934         * @return                                               An error code
935         * @exception                                    E_SUCCESS                                       The method is successful.
936         * @exception                                    E_OUT_OF_RANGE  The time fields contain an invalid value. @n
937         *                                                               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.
938         */
939         virtual result ComputeTimeFields(void) = 0;
940
941         /**
942         * Computes the time value. @n
943         * Converts the current values of time field to the millisecond time value.
944         *
945         * @since                                                2.0
946         *
947         * @return                                               An error code
948         * @exception                                    E_SUCCESS                                       The method is successful.
949         * @exception                                    E_INVALID_STATE                         A value of the internal time field is invalid.
950         */
951         virtual result ComputeTime(void) = 0;
952
953         /**
954         * Gets the length of the specified month.
955         *
956         * @since                                                2.0
957         *
958         * @return                                               An integer value indicating the number of days in the specified month
959         * @param[in]                                    extendedYear                            An extended year
960         * @param[in]                                    month                                           A month
961         */
962         virtual int GetMonthLength(int extendedYear, int month) const = 0;
963
964         /**
965         * Handles the limits of different types. @n
966         * Derived classes must implement this method for the following fields:
967         * TIME_FIELD_ERA, TIME_FIELD_YEAR, TIME_FIELD_MONTH, TIME_FIELD_WEEK_OF_YEAR, TIME_FIELD_WEEK_OF_MONTH,
968         * TIME_FIELD_DAY_OF_MONTH, TIME_FIELD_DAY_OF_YEAR, TIME_FIELD_DAY_OF_WEEK_IN_MONTH, TIME_FIELD_YEAR_WOY,
969         * TIME_FIELD_EXTENDED_YEAR.
970         *
971         * @since                                                2.0
972         *
973         * @return                                               The limit of the specified field
974         * @param[in]                                    field                                           The time field
975         * @param[in]                                    limitType                                       The type of limit
976         */
977         virtual int HandleGetLimit(TimeField field, CalendarLimitType limitType) const = 0;
978
979         /*
980         * Creates and returns a polymorphic copy of this calendar.
981         *
982         * @since                                                2.0
983         *
984         * @return                                       A polymorphic copy of this calendar
985         */
986         virtual Tizen::Locales::Calendar* CloneN(void) const = 0;
987
988         //
989         // This method is for internal use only. Using this method can cause behavioral, security-related,
990         // and consistency-related issues in the application.
991         //
992         // This method is reserved and may change its name at any time without prior notice.
993         //
994         // @since       2.0
995         //
996         virtual void Calendar_Reserved1(void) { }
997
998         //
999         // This method is for internal use only. Using this method can cause behavioral, security-related,
1000         // and consistency-related issues in the application.
1001         //
1002         // This method is reserved and may change its name at any time without prior notice.
1003         //
1004         // @since       2.0
1005         //
1006         virtual void Calendar_Reserved2(void) { }
1007
1008         //
1009         // This method is for internal use only. Using this method can cause behavioral, security-related,
1010         // and consistency-related issues in the application.
1011         //
1012         // This method is reserved and may change its name at any time without prior notice.
1013         //
1014         // @since       2.0
1015         //
1016         virtual void Calendar_Reserved3(void) { }
1017
1018         //
1019         // This method is for internal use only. Using this method can cause behavioral, security-related,
1020         // and consistency-related issues in the application.
1021         //
1022         // This method is reserved and may change its name at any time without prior notice.
1023         //
1024         // @since       2.0
1025         //
1026         virtual void Calendar_Reserved4(void) { }
1027
1028         //
1029         // This method is for internal use only. Using this method can cause behavioral, security-related,
1030         // and consistency-related issues in the application.
1031         //
1032         // This method is reserved and may change its name at any time without prior notice.
1033         //
1034         // @since       2.0
1035         //
1036         virtual void Calendar_Reserved5(void) { }
1037
1038 private:
1039         /**
1040          * The implementation of this copy constructor is intentionally blank and declared as private to
1041          * prohibit copying of objects. Use CloneN() to get an exact copy of the instance.
1042          */
1043         Calendar(const Calendar& calendar);
1044
1045         /**
1046          * The implementation of this copy assignment operator is intentionally blank and declared as private
1047          * to prohibit copying of objects. Use CloneN() to get an exact copy of the instance.
1048          */
1049         Calendar& operator =(const Calendar& calendar);
1050
1051 public:
1052         /**
1053          * Millisecond constants for one day.
1054          *
1055          * @since       2.0
1056          */
1057         static const int ONE_DAY_IN_MILLISEC = 86400000;
1058
1059         /**
1060          * Millisecond constants for one hour.
1061          *
1062          * @since       2.0
1063          */
1064         static const int ONE_HOUR_IN_MILLISEC = 60 * 60 * 1000;
1065
1066         /**
1067          * Millisecond constants for one minute.
1068          *
1069          * @since       2.0
1070          */
1071         static const int ONE_MINUTE_IN_MILLISEC = 60000;
1072
1073         /**
1074          * Millisecond constants for one second.
1075          *
1076          * @since       2.0
1077          */
1078         static const int ONE_SECOND_IN_MILLISEC = 1000;
1079
1080         /**
1081          * Millisecond constants for one week.
1082          *
1083          * @since       2.0
1084          */
1085         static const long long ONE_WEEK_IN_MILLISEC = 7 * ONE_DAY_IN_MILLISEC;
1086
1087 protected:
1088         /*
1089          * The field values for the currently set time for this calendar.
1090          */
1091         int _timeFields[TIME_FIELD_FIELD_COUNT];
1092
1093         /*
1094          * Pseudo-time-stamps which specify when each field is set.
1095          * There are two special values - UNSET and INTERNALLY_SET.
1096          */
1097         int _stamp[TIME_FIELD_FIELD_COUNT];
1098
1099         /*
1100          * The flags which tell if a specified time field for the calendar is set.
1101          */
1102         bool _isSet[TIME_FIELD_FIELD_COUNT];
1103
1104         long long _time; // UTC time
1105         Tizen::Locales::TimeZone _timeZone;
1106
1107         bool _isTimeSet;
1108         bool _areFieldsSet;
1109         bool _areAllFieldsSet;
1110         int _nextStamp;
1111         bool _isLenient;
1112         bool _isConstructed;
1113
1114         // Mask values for calendar fields
1115         static const int ERA_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_ERA);
1116         static const int YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_YEAR);
1117         static const int MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MONTH);
1118         static const int WEEK_OF_YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_WEEK_OF_YEAR);
1119         static const int WEEK_OF_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_WEEK_OF_MONTH);
1120         static const int DAY_OF_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_MONTH);
1121         static const int DAY_OF_YEAR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_YEAR);
1122         static const int DAY_OF_WEEK_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_WEEK);
1123         static const int DAY_OF_WEEK_IN_MONTH_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DAY_OF_WEEK_IN_MONTH);
1124         static const int AM_PM_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_AM_PM);
1125         static const int HOUR_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_HOUR);
1126         static const int HOUR_OF_DAY_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_HOUR_OF_DAY);
1127         static const int MINUTE_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MINUTE);
1128         static const int SECOND_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_SECOND);
1129         static const int MILLISECOND_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_MILLISECOND);
1130         static const int ZONE_OFFSET_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_ZONE_OFFSET);
1131         static const int DST_OFFSET_MASK = GET_TIME_FIELD_MASK(TIME_FIELD_DST_OFFSET);
1132         static const int ALL_FIELDS = GET_TIME_FIELD_MASK(TIME_FIELD_FIELD_COUNT) - 1;
1133
1134 //private:
1135         friend class _CalendarImpl;
1136         class _CalendarImpl* _pCalendarImpl;
1137
1138 }; // Calendar
1139
1140 }} // Tizen::Locales
1141
1142 #endif //_FLCL_CALENDAR_H_