mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-2223 Port weekend APIs from ICU4J to C,C++ (dummy implementation for now)
X-SVN-Rev: 27292
This commit is contained in:
parent
285259186d
commit
8e57ee7bac
4 changed files with 209 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2009, International Business Machines Corporation and *
|
||||
* Copyright (C) 1997-2010, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*
|
||||
|
@ -2093,6 +2093,46 @@ Calendar::getMinimalDaysInFirstWeek() const
|
|||
return fMinimalDaysInFirstWeek;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// weekend functions, just dummy implementations for now (for API freeze)
|
||||
|
||||
UCalendarWeekdayType
|
||||
Calendar::getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
|
||||
{
|
||||
if (U_FAILURE(status)) {
|
||||
return UCAL_WEEKDAY;
|
||||
}
|
||||
return ((dayOfWeek > UCAL_SUNDAY && dayOfWeek < UCAL_SATURDAY)? UCAL_WEEKDAY: UCAL_WEEKEND);
|
||||
}
|
||||
|
||||
int32_t
|
||||
Calendar::getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
|
||||
{
|
||||
if (U_FAILURE(status)) {
|
||||
return 0;
|
||||
}
|
||||
if (dayOfWeek > UCAL_SUNDAY && dayOfWeek < UCAL_SATURDAY) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
UBool
|
||||
Calendar::isWeekend(UDate date, UErrorCode &status) const
|
||||
{
|
||||
if (U_FAILURE(status)) {
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UBool
|
||||
Calendar::isWeekend(void) const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------- limits
|
||||
|
||||
int32_t
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2009, International Business Machines
|
||||
* Copyright (C) 1996-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -533,6 +533,34 @@ ucal_getType(const UCalendar *cal, UErrorCode* status)
|
|||
return ((Calendar*)cal)->getType();
|
||||
}
|
||||
|
||||
U_CAPI UCalendarWeekdayType U_EXPORT2
|
||||
ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status)
|
||||
{
|
||||
if (U_FAILURE(*status)) {
|
||||
return UCAL_WEEKDAY;
|
||||
}
|
||||
return ((Calendar*)cal)->getDayOfWeekType(dayOfWeek, *status);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status)
|
||||
{
|
||||
if (U_FAILURE(*status)) {
|
||||
return 0;
|
||||
}
|
||||
return ((Calendar*)cal)->getWeekendTransition(dayOfWeek, *status);
|
||||
}
|
||||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status)
|
||||
{
|
||||
if (U_FAILURE(*status)) {
|
||||
return FALSE;
|
||||
}
|
||||
return ((Calendar*)cal)->isWeekend(date, *status);
|
||||
}
|
||||
|
||||
|
||||
static const UEnumeration defaultKeywordValues = {
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
********************************************************************************
|
||||
* Copyright (C) 1997-2009, International Business Machines
|
||||
* Copyright (C) 1997-2010, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
********************************************************************************
|
||||
*
|
||||
|
@ -1190,6 +1190,59 @@ public:
|
|||
*/
|
||||
virtual const char * getType() const = 0;
|
||||
|
||||
/**
|
||||
* Returns whether the given day of the week is a weekday, a
|
||||
* weekend day, or a day that transitions from one to the other,
|
||||
* in this calendar system. If a transition occurs at midnight,
|
||||
* then the days before and after the transition will have the
|
||||
* type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
|
||||
* other than midnight, then the day of the transition will have
|
||||
* the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
|
||||
* method getWeekendTransition() will return the point of
|
||||
* transition.
|
||||
* @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
||||
* @param status The error code for the operation.
|
||||
* @return The UCalendarWeekdayType for the day of the week.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
|
||||
|
||||
/**
|
||||
* Returns the time during the day at which the weekend begins or ends in
|
||||
* this calendar system. If getDayOfWeekType() rerturns UCAL_WEEKEND_ONSET
|
||||
* for the specified dayOfWeek, return the time at which the weekend begins.
|
||||
* If getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
|
||||
* return the time at which the weekend ends. If getDayOfWeekType() returns
|
||||
* some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
|
||||
* (U_ILLEGAL_ARGUMENT_ERROR).
|
||||
* @param dayOfWeek The day of the week for which the weekend transition time is
|
||||
* desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
||||
* @param status The error code for the operation.
|
||||
* @return The milliseconds after midnight at which the weekend begins or ends.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if the given UDate is in the weekend in
|
||||
* this calendar system.
|
||||
* @param date The UDate in question.
|
||||
* @param status The error code for the operation.
|
||||
* @return TRUE if the given UDate is in the weekend in
|
||||
* this calendar system, FALSE otherwise.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
virtual UBool isWeekend(UDate date, UErrorCode &status) const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if this Calendar's current date-time is in the weekend in
|
||||
* this calendar system.
|
||||
* @return TRUE if this Calendar's current date-time is in the weekend in
|
||||
* this calendar system, FALSE otherwise.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
virtual UBool isWeekend(void) const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2009, International Business Machines Corporation and
|
||||
* Copyright (C) 1996-2010, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -156,16 +156,16 @@ enum UCalendarType {
|
|||
* @stable ICU 2.0
|
||||
*/
|
||||
UCAL_TRADITIONAL,
|
||||
/**
|
||||
* Unambiguously designates the Gregorian calendar for the locale.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UCAL_GREGORIAN,
|
||||
/**
|
||||
* A better name for UCAL_TRADITIONAL.
|
||||
* @draft ICU 4.2
|
||||
*/
|
||||
UCAL_DEFAULT = UCAL_TRADITIONAL
|
||||
UCAL_DEFAULT = UCAL_TRADITIONAL,
|
||||
/**
|
||||
* Unambiguously designates the Gregorian calendar for the locale.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
UCAL_GREGORIAN
|
||||
};
|
||||
|
||||
/** @stable ICU 2.0 */
|
||||
|
@ -1198,6 +1198,84 @@ ucal_getKeywordValuesForLocale(const char* key,
|
|||
UErrorCode* status);
|
||||
|
||||
|
||||
/** Weekday types, as returned by ucal_getDayOfWeekType().
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
enum UCalendarWeekdayType {
|
||||
/**
|
||||
* Designates a full weekday (no part of the day is included in the weekend).
|
||||
*/
|
||||
UCAL_WEEKDAY,
|
||||
/**
|
||||
* Designates a full weekend day (the entire day is included in the weekend).
|
||||
*/
|
||||
UCAL_WEEKEND,
|
||||
/**
|
||||
* Designates a day that starts as a weekday and transitions to the weekend.
|
||||
* Call ucal_getWeekendTransition() to get the time of transition.
|
||||
*/
|
||||
UCAL_WEEKEND_ONSET,
|
||||
/**
|
||||
* Designates a day that starts as the weekend and transitions to a weekday.
|
||||
* Call ucal_getWeekendTransition() to get the time of transition.
|
||||
*/
|
||||
UCAL_WEEKEND_CEASE
|
||||
};
|
||||
|
||||
/** @draft ICU 4.4 */
|
||||
typedef enum UCalendarWeekdayType UCalendarWeekdayType;
|
||||
|
||||
/**
|
||||
* Returns whether the given day of the week is a weekday, a
|
||||
* weekend day, or a day that transitions from one to the other,
|
||||
* in this calendar system. If a transition occurs at midnight,
|
||||
* then the days before and after the transition will have the
|
||||
* type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
|
||||
* other than midnight, then the day of the transition will have
|
||||
* the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
|
||||
* method getWeekendTransition() will return the point of
|
||||
* transition.
|
||||
* @param cal The UCalendar to query.
|
||||
* @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
||||
* @param status The error code for the operation.
|
||||
* @return The UCalendarWeekdayType for the day of the week.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
U_DRAFT UCalendarWeekdayType U_EXPORT2
|
||||
ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);
|
||||
|
||||
/**
|
||||
* Returns the time during the day at which the weekend begins or ends in
|
||||
* this calendar system. If ucal_getDayOfWeekType() rerturns UCAL_WEEKEND_ONSET
|
||||
* for the specified dayOfWeek, return the time at which the weekend begins.
|
||||
* If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
|
||||
* return the time at which the weekend ends. If ucal_getDayOfWeekType() returns
|
||||
* some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
|
||||
* (U_ILLEGAL_ARGUMENT_ERROR).
|
||||
* @param cal The UCalendar to query.
|
||||
* @param dayOfWeek The day of the week for which the weekend transition time is
|
||||
* desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
||||
* @param status The error code for the operation.
|
||||
* @return The milliseconds after midnight at which the weekend begins or ends.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
U_DRAFT int32_t U_EXPORT2
|
||||
ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);
|
||||
|
||||
/**
|
||||
* Returns TRUE if the given UDate is in the weekend in
|
||||
* this calendar system.
|
||||
* @param cal The UCalendar to query.
|
||||
* @param date The UDate in question.
|
||||
* @param status The error code for the operation.
|
||||
* @return TRUE if the given UDate is in the weekend in
|
||||
* this calendar system, FALSE otherwise.
|
||||
* @draft ICU 4.4
|
||||
*/
|
||||
U_DRAFT UBool U_EXPORT2
|
||||
ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
|
||||
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue