ICU-887 add new ucal_ time zone API
X-SVN-Rev: 11249
This commit is contained in:
parent
efda501285
commit
03c212daf4
@ -13,6 +13,7 @@
|
|||||||
#include "unicode/uloc.h"
|
#include "unicode/uloc.h"
|
||||||
#include "unicode/calendar.h"
|
#include "unicode/calendar.h"
|
||||||
#include "unicode/timezone.h"
|
#include "unicode/timezone.h"
|
||||||
|
#include "unicode/simpletz.h"
|
||||||
#include "unicode/ustring.h"
|
#include "unicode/ustring.h"
|
||||||
#include "unicode/strenum.h"
|
#include "unicode/strenum.h"
|
||||||
#include "cmemory.h"
|
#include "cmemory.h"
|
||||||
@ -20,9 +21,67 @@
|
|||||||
|
|
||||||
U_NAMESPACE_USE
|
U_NAMESPACE_USE
|
||||||
|
|
||||||
|
static TimeZone*
|
||||||
|
_createTimeZone(const UChar* zoneID, int32_t len, UErrorCode* ec) {
|
||||||
|
TimeZone* zone = NULL;
|
||||||
|
if (ec!=NULL && U_SUCCESS(*ec)) {
|
||||||
|
// Note that if zoneID is invalid, we get back GMT. This odd
|
||||||
|
// behavior is by design and goes back to the JDK. The only
|
||||||
|
// failure we will see is a memory allocation failure.
|
||||||
|
int32_t l = (len<0 ? u_strlen(zoneID) : len);
|
||||||
|
zone = TimeZone::createTimeZone(UnicodeString(zoneID, l));
|
||||||
|
if (zone == NULL) {
|
||||||
|
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return zone;
|
||||||
|
}
|
||||||
|
|
||||||
U_CAPI UEnumeration* U_EXPORT2
|
U_CAPI UEnumeration* U_EXPORT2
|
||||||
ucal_openTimeZoneEnumeration(int32_t rawOffset, UErrorCode* ec) {
|
ucal_openTimeZones(UErrorCode* ec) {
|
||||||
return uenum_openStringEnumeration(TimeZone::createEnumeration(rawOffset), ec);
|
return uenum_openStringEnumeration(TimeZone::createEnumeration(), ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
U_CAPI UEnumeration* U_EXPORT2
|
||||||
|
ucal_openCountryTimeZones(const char* country, UErrorCode* ec) {
|
||||||
|
return uenum_openStringEnumeration(TimeZone::createEnumeration(country), ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec) {
|
||||||
|
int32_t len = 0;
|
||||||
|
if (ec!=NULL && U_SUCCESS(*ec)) {
|
||||||
|
TimeZone* zone = TimeZone::createDefault();
|
||||||
|
if (zone == NULL) {
|
||||||
|
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||||
|
} else {
|
||||||
|
UnicodeString id;
|
||||||
|
zone->getID(id);
|
||||||
|
delete zone;
|
||||||
|
len = id.extract(result, resultCapacity, *ec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_CAPI void U_EXPORT2
|
||||||
|
ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec) {
|
||||||
|
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
|
||||||
|
if (zone != NULL) {
|
||||||
|
TimeZone::adoptDefault(zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec) {
|
||||||
|
int32_t result = 0;
|
||||||
|
TimeZone* zone = _createTimeZone(zoneID, -1, ec);
|
||||||
|
if (U_SUCCESS(*ec) &&
|
||||||
|
zone->getDynamicClassID() == SimpleTimeZone::getStaticClassID()) {
|
||||||
|
result = ((SimpleTimeZone*) zone)->getDSTSavings();
|
||||||
|
}
|
||||||
|
delete zone;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
U_CAPI const UChar* U_EXPORT2
|
U_CAPI const UChar* U_EXPORT2
|
||||||
@ -89,18 +148,11 @@ ucal_open( const UChar* zoneID,
|
|||||||
|
|
||||||
if(U_FAILURE(*status)) return 0;
|
if(U_FAILURE(*status)) return 0;
|
||||||
|
|
||||||
TimeZone *zone = 0;
|
TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault()
|
||||||
if(zoneID == 0) {
|
: _createTimeZone(zoneID, len, status);
|
||||||
zone = TimeZone::createDefault();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int32_t length = (len == -1 ? u_strlen(zoneID) : len);
|
|
||||||
|
|
||||||
zone = TimeZone::createTimeZone(UnicodeString(zoneID, length));
|
if (U_FAILURE(*status)) {
|
||||||
}
|
return NULL;
|
||||||
if(zone == 0) {
|
|
||||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status);
|
return (UCalendar*)Calendar::createInstance(zone, Locale(locale), *status);
|
||||||
@ -123,21 +175,12 @@ ucal_setTimeZone( UCalendar* cal,
|
|||||||
if(U_FAILURE(*status))
|
if(U_FAILURE(*status))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TimeZone *zone;
|
TimeZone* zone = (zoneID==NULL) ? TimeZone::createDefault()
|
||||||
if(zoneID == NULL) {
|
: _createTimeZone(zoneID, len, status);
|
||||||
zone = TimeZone::createDefault();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int32_t length = (len == -1 ? u_strlen(zoneID) : len);
|
|
||||||
zone = TimeZone::createTimeZone(UnicodeString((UChar*)zoneID,
|
|
||||||
length, length));
|
|
||||||
}
|
|
||||||
if(zone == 0) {
|
|
||||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((Calendar*)cal)->adoptTimeZone(zone);
|
if (zone != NULL) {
|
||||||
|
((Calendar*)cal)->adoptTimeZone(zone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
@ -280,98 +280,142 @@ enum UCalendarAMPMs {
|
|||||||
typedef enum UCalendarAMPMs UCalendarAMPMs;
|
typedef enum UCalendarAMPMs UCalendarAMPMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a UEnumeration over the recognized time zone IDs with the
|
* Create an enumeration over all time zones.
|
||||||
* given raw offset.
|
*
|
||||||
* @param rawOffset the desired GMT offset, not including the effects
|
* @param ec input/output error code
|
||||||
* of daylight savings time
|
*
|
||||||
* @return an enumeration object that the caller must dispose of using
|
* @return an enumeration object that the caller must dispose of using
|
||||||
* uenum_close()
|
* uenum_close(), or NULL upon failure. In case of failure *ec will
|
||||||
* @draft ICU 2.4
|
* indicate the error.
|
||||||
|
*
|
||||||
|
* @draft ICU 2.6
|
||||||
*/
|
*/
|
||||||
U_CAPI UEnumeration* U_EXPORT2
|
U_CAPI UEnumeration* U_EXPORT2
|
||||||
ucal_openTimeZoneEnumeration(int32_t rawOffset,
|
ucal_openTimeZones(UErrorCode* ec);
|
||||||
UErrorCode* status);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an available TimeZone ID.
|
* Create an enumeration over all time zones associated with the given
|
||||||
* A Timezone ID is a string of the form "America/Los Angeles".
|
* country. Some zones are affiliated with no country (e.g., "UTC");
|
||||||
* @param rawOffset The desired GMT offset
|
* these may also be retrieved, as a group.
|
||||||
* @param index The index of the desired TimeZone.
|
*
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param country the ISO 3166 two-letter country code, or NULL to
|
||||||
* @return The requested TimeZone ID, or 0 if not found
|
* retrieve zones not affiliated with any country
|
||||||
* @see ucal_countAvailableTZIDs
|
*
|
||||||
* @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
|
* @param ec input/output error code
|
||||||
*/
|
*
|
||||||
U_CAPI const UChar* U_EXPORT2
|
* @return an enumeration object that the caller must dispose of using
|
||||||
ucal_getAvailableTZIDs( int32_t rawOffset,
|
* uenum_close(), or NULL upon failure. In case of failure *ec will
|
||||||
int32_t index,
|
* indicate the error.
|
||||||
UErrorCode* status);
|
*
|
||||||
|
* @draft ICU 2.6
|
||||||
|
*/
|
||||||
|
U_CAPI UEnumeration* U_EXPORT2
|
||||||
|
ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine how many TimeZones exist with a certain offset.
|
* Return the default time zone. The default is determined initially
|
||||||
* This function is most useful as determining the loop ending condition for
|
* by querying the host operating system. It may be changed with
|
||||||
* calls to \Ref{ucal_getAvailableTZIDs}.
|
* ucal_setDefaultTimeZone() or with the C++ TimeZone API.
|
||||||
* @param rawOffset The desired GMT offset.
|
*
|
||||||
* @return The number of TimeZones with rawOffset.
|
* @param result a buffer to receive the result, or NULL
|
||||||
* @see ucal_getAvailableTZIDs
|
*
|
||||||
* @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
|
* @param resultLength the length of the result buffer
|
||||||
*/
|
*
|
||||||
U_CAPI int32_t U_EXPORT2
|
* @param ec input/output error code
|
||||||
ucal_countAvailableTZIDs(int32_t rawOffset);
|
*
|
||||||
|
* @return the result string length, not including the terminating
|
||||||
|
* null
|
||||||
|
*
|
||||||
|
* @draft ICU 2.6
|
||||||
|
*/
|
||||||
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current date and time.
|
* Set the default time zone.
|
||||||
* The value returned is represented as milliseconds from the epoch.
|
*
|
||||||
* @return The current date and time.
|
* @param zoneID null-terminated time zone ID
|
||||||
* @stable ICU 2.0
|
*
|
||||||
*/
|
* @param ec input/output error code
|
||||||
|
*
|
||||||
|
* @draft ICU 2.6
|
||||||
|
*/
|
||||||
|
U_CAPI void U_EXPORT2
|
||||||
|
ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the amount of time in milliseconds that the clock is
|
||||||
|
* advanced during daylight savings time for the given time zone, or
|
||||||
|
* zero if the time zone does not observe daylight savings time.
|
||||||
|
*
|
||||||
|
* @param zoneID null-terminated time zone ID
|
||||||
|
*
|
||||||
|
* @param ec input/output error code
|
||||||
|
*
|
||||||
|
* @return the number of milliseconds the time is advanced with
|
||||||
|
* respect to standard time when the daylight savings rules are in
|
||||||
|
* effect. This is always a non-negative number, most commonly either
|
||||||
|
* 3,600,000 (one hour) or zero.
|
||||||
|
*
|
||||||
|
* @draft ICU 2.6
|
||||||
|
*/
|
||||||
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current date and time.
|
||||||
|
* The value returned is represented as milliseconds from the epoch.
|
||||||
|
* @return The current date and time.
|
||||||
|
* @stable ICU 2.0
|
||||||
|
*/
|
||||||
U_CAPI UDate U_EXPORT2
|
U_CAPI UDate U_EXPORT2
|
||||||
ucal_getNow(void);
|
ucal_getNow(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a UCalendar.
|
* Open a UCalendar.
|
||||||
* A UCalendar may be used to convert a millisecond value to a year,
|
* A UCalendar may be used to convert a millisecond value to a year,
|
||||||
* month, and day.
|
* month, and day.
|
||||||
* @param zoneID The desired TimeZone ID. If 0, use the default time zone.
|
* @param zoneID The desired TimeZone ID. If 0, use the default time zone.
|
||||||
* @param len The length of zoneID, or -1 if null-terminated.
|
* @param len The length of zoneID, or -1 if null-terminated.
|
||||||
* @param locale The desired locale
|
* @param locale The desired locale
|
||||||
* @param type The type of UCalendar to open.
|
* @param type The type of UCalendar to open.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @return A pointer to a UCalendar, or 0 if an error occurred.
|
* @return A pointer to a UCalendar, or 0 if an error occurred.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI UCalendar* U_EXPORT2
|
U_CAPI UCalendar* U_EXPORT2
|
||||||
ucal_open( const UChar* zoneID,
|
ucal_open(const UChar* zoneID,
|
||||||
int32_t len,
|
int32_t len,
|
||||||
const char* locale,
|
const char* locale,
|
||||||
UCalendarType type,
|
UCalendarType type,
|
||||||
UErrorCode* status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a UCalendar.
|
* Close a UCalendar.
|
||||||
* Once closed, a UCalendar may no longer be used.
|
* Once closed, a UCalendar may no longer be used.
|
||||||
* @param cal The UCalendar to close.
|
* @param cal The UCalendar to close.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_close(UCalendar *cal);
|
ucal_close(UCalendar *cal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the TimeZone used by a UCalendar.
|
* Set the TimeZone used by a UCalendar.
|
||||||
* A UCalendar uses a timezone for converting from Greenwich time to local time.
|
* A UCalendar uses a timezone for converting from Greenwich time to local time.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param zoneID The desired TimeZone ID. If 0, use the default time zone.
|
* @param zoneID The desired TimeZone ID. If 0, use the default time zone.
|
||||||
* @param len The length of zoneID, or -1 if null-terminated.
|
* @param len The length of zoneID, or -1 if null-terminated.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors.
|
* @param status A pointer to an UErrorCode to receive any errors.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_setTimeZone( UCalendar* cal,
|
ucal_setTimeZone(UCalendar* cal,
|
||||||
const UChar* zoneID,
|
const UChar* zoneID,
|
||||||
int32_t len,
|
int32_t len,
|
||||||
UErrorCode *status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/** Possible formats for a UCalendar's display name
|
/**
|
||||||
|
* Possible formats for a UCalendar's display name
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
enum UCalendarDisplayNameType {
|
enum UCalendarDisplayNameType {
|
||||||
@ -389,39 +433,40 @@ enum UCalendarDisplayNameType {
|
|||||||
typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
|
typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the display name for a UCalendar's TimeZone.
|
* Get the display name for a UCalendar's TimeZone.
|
||||||
* A display name is suitable for presentation to a user.
|
* A display name is suitable for presentation to a user.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
|
* @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
|
||||||
* UCAL_DST, UCAL_SHORT_DST
|
* UCAL_DST, UCAL_SHORT_DST
|
||||||
* @param locale The desired locale for the display name.
|
* @param locale The desired locale for the display name.
|
||||||
* @param result A pointer to a buffer to receive the formatted number.
|
* @param result A pointer to a buffer to receive the formatted number.
|
||||||
* @param resultLength The maximum size of result.
|
* @param resultLength The maximum size of result.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
|
* @return The total buffer size needed; if greater than resultLength, the output was truncated.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
ucal_getTimeZoneDisplayName( const UCalendar* cal,
|
ucal_getTimeZoneDisplayName(const UCalendar* cal,
|
||||||
UCalendarDisplayNameType type,
|
UCalendarDisplayNameType type,
|
||||||
const char *locale,
|
const char* locale,
|
||||||
UChar* result,
|
UChar* result,
|
||||||
int32_t resultLength,
|
int32_t resultLength,
|
||||||
UErrorCode* status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a UCalendar is currently in daylight savings time.
|
* Determine if a UCalendar is currently in daylight savings time.
|
||||||
* Daylight savings time is not used in all parts of the world.
|
* Daylight savings time is not used in all parts of the world.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @return TRUE if cal is currently in daylight savings time, FALSE otherwise
|
* @return TRUE if cal is currently in daylight savings time, FALSE otherwise
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI UBool U_EXPORT2
|
U_CAPI UBool U_EXPORT2
|
||||||
ucal_inDaylightTime( const UCalendar* cal,
|
ucal_inDaylightTime(const UCalendar* cal,
|
||||||
UErrorCode* status );
|
UErrorCode* status );
|
||||||
|
|
||||||
/** Types of UCalendar attributes
|
/**
|
||||||
|
* Types of UCalendar attributes
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
enum UCalendarAttribute {
|
enum UCalendarAttribute {
|
||||||
@ -437,137 +482,137 @@ enum UCalendarAttribute {
|
|||||||
typedef enum UCalendarAttribute UCalendarAttribute;
|
typedef enum UCalendarAttribute UCalendarAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a numeric attribute associated with a UCalendar.
|
* Get a numeric attribute associated with a UCalendar.
|
||||||
* Numeric attributes include the first day of the week, or the minimal numbers
|
* Numeric attributes include the first day of the week, or the minimal numbers
|
||||||
* of days in the first week of the month.
|
* of days in the first week of the month.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
|
* @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
|
||||||
* or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
|
* or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
|
||||||
* @return The value of attr.
|
* @return The value of attr.
|
||||||
* @see ucal_setAttribute
|
* @see ucal_setAttribute
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
ucal_getAttribute( const UCalendar* cal,
|
ucal_getAttribute(const UCalendar* cal,
|
||||||
UCalendarAttribute attr);
|
UCalendarAttribute attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a numeric attribute associated with a UCalendar.
|
* Set a numeric attribute associated with a UCalendar.
|
||||||
* Numeric attributes include the first day of the week, or the minimal numbers
|
* Numeric attributes include the first day of the week, or the minimal numbers
|
||||||
* of days in the first week of the month.
|
* of days in the first week of the month.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
|
* @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
|
||||||
* or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
|
* or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
|
||||||
* @param newValue The new value of attr.
|
* @param newValue The new value of attr.
|
||||||
* @see ucal_getAttribute
|
* @see ucal_getAttribute
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_setAttribute( UCalendar* cal,
|
ucal_setAttribute(UCalendar* cal,
|
||||||
UCalendarAttribute attr,
|
UCalendarAttribute attr,
|
||||||
int32_t newValue);
|
int32_t newValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a locale for which calendars are available.
|
* Get a locale for which calendars are available.
|
||||||
* A UCalendar in a locale returned by this function will contain the correct
|
* A UCalendar in a locale returned by this function will contain the correct
|
||||||
* day and month names for the locale.
|
* day and month names for the locale.
|
||||||
* @param index The index of the desired locale.
|
* @param index The index of the desired locale.
|
||||||
* @return A locale for which calendars are available, or 0 if none.
|
* @return A locale for which calendars are available, or 0 if none.
|
||||||
* @see ucal_countAvailable
|
* @see ucal_countAvailable
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI const char* U_EXPORT2
|
U_CAPI const char* U_EXPORT2
|
||||||
ucal_getAvailable(int32_t index);
|
ucal_getAvailable(int32_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine how many locales have calendars available.
|
* Determine how many locales have calendars available.
|
||||||
* This function is most useful as determining the loop ending condition for
|
* This function is most useful as determining the loop ending condition for
|
||||||
* calls to \Ref{ucal_getAvailable}.
|
* calls to \Ref{ucal_getAvailable}.
|
||||||
* @return The number of locales for which calendars are available.
|
* @return The number of locales for which calendars are available.
|
||||||
* @see ucal_getAvailable
|
* @see ucal_getAvailable
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
ucal_countAvailable(void);
|
ucal_countAvailable(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a UCalendar's current time in millis.
|
* Get a UCalendar's current time in millis.
|
||||||
* The time is represented as milliseconds from the epoch.
|
* The time is represented as milliseconds from the epoch.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @return The calendar's current time in millis.
|
* @return The calendar's current time in millis.
|
||||||
* @see ucal_setMillis
|
* @see ucal_setMillis
|
||||||
* @see ucal_setDate
|
* @see ucal_setDate
|
||||||
* @see ucal_setDateTime
|
* @see ucal_setDateTime
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI UDate U_EXPORT2
|
U_CAPI UDate U_EXPORT2
|
||||||
ucal_getMillis( const UCalendar* cal,
|
ucal_getMillis(const UCalendar* cal,
|
||||||
UErrorCode* status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a UCalendar's current time in millis.
|
* Set a UCalendar's current time in millis.
|
||||||
* The time is represented as milliseconds from the epoch.
|
* The time is represented as milliseconds from the epoch.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param dateTime The desired date and time.
|
* @param dateTime The desired date and time.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @see ucal_getMillis
|
* @see ucal_getMillis
|
||||||
* @see ucal_setDate
|
* @see ucal_setDate
|
||||||
* @see ucal_setDateTime
|
* @see ucal_setDateTime
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_setMillis( UCalendar* cal,
|
ucal_setMillis(UCalendar* cal,
|
||||||
UDate dateTime,
|
UDate dateTime,
|
||||||
UErrorCode* status );
|
UErrorCode* status );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a UCalendar's current date.
|
* Set a UCalendar's current date.
|
||||||
* The date is represented as a series of 32-bit integers.
|
* The date is represented as a series of 32-bit integers.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param year The desired year.
|
* @param year The desired year.
|
||||||
* @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
|
* @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
|
||||||
* UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
|
* UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
|
||||||
* @param date The desired day of the month.
|
* @param date The desired day of the month.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @see ucal_getMillis
|
* @see ucal_getMillis
|
||||||
* @see ucal_setMillis
|
* @see ucal_setMillis
|
||||||
* @see ucal_setDateTime
|
* @see ucal_setDateTime
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_setDate( UCalendar* cal,
|
ucal_setDate(UCalendar* cal,
|
||||||
int32_t year,
|
int32_t year,
|
||||||
int32_t month,
|
int32_t month,
|
||||||
int32_t date,
|
int32_t date,
|
||||||
UErrorCode *status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a UCalendar's current date.
|
* Set a UCalendar's current date.
|
||||||
* The date is represented as a series of 32-bit integers.
|
* The date is represented as a series of 32-bit integers.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param year The desired year.
|
* @param year The desired year.
|
||||||
* @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
|
* @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
|
||||||
* UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
|
* UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
|
||||||
* @param date The desired day of the month.
|
* @param date The desired day of the month.
|
||||||
* @param hour The desired hour of day.
|
* @param hour The desired hour of day.
|
||||||
* @param minute The desired minute.
|
* @param minute The desired minute.
|
||||||
* @param second The desirec second.
|
* @param second The desirec second.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @see ucal_getMillis
|
* @see ucal_getMillis
|
||||||
* @see ucal_setMillis
|
* @see ucal_setMillis
|
||||||
* @see ucal_setDate
|
* @see ucal_setDate
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_setDateTime( UCalendar* cal,
|
ucal_setDateTime(UCalendar* cal,
|
||||||
int32_t year,
|
int32_t year,
|
||||||
int32_t month,
|
int32_t month,
|
||||||
int32_t date,
|
int32_t date,
|
||||||
int32_t hour,
|
int32_t hour,
|
||||||
int32_t minute,
|
int32_t minute,
|
||||||
int32_t second,
|
int32_t second,
|
||||||
UErrorCode *status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns TRUE if two UCalendars are equivalent. Equivalent
|
* Returns TRUE if two UCalendars are equivalent. Equivalent
|
||||||
@ -579,143 +624,144 @@ ucal_setDateTime( UCalendar* cal,
|
|||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI UBool U_EXPORT2
|
U_CAPI UBool U_EXPORT2
|
||||||
ucal_equivalentTo(const UCalendar* cal1,
|
ucal_equivalentTo(const UCalendar* cal1,
|
||||||
const UCalendar* cal2);
|
const UCalendar* cal2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a specified signed amount to a particular field in a UCalendar.
|
* Add a specified signed amount to a particular field in a UCalendar.
|
||||||
* This can modify more significant fields in the calendar.
|
* This can modify more significant fields in the calendar.
|
||||||
* @param cal The UCalendar to which to add.
|
* @param cal The UCalendar to which to add.
|
||||||
* @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @param amount The signed amount to add to field. If the amount causes the value
|
* @param amount The signed amount to add to field. If the amount causes the value
|
||||||
* to exceed to maximum or minimum values for that field, other fields are modified
|
* to exceed to maximum or minimum values for that field, other fields are modified
|
||||||
* to preserve the magnitude of the change.
|
* to preserve the magnitude of the change.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @see ucal_roll
|
* @see ucal_roll
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_add( UCalendar* cal,
|
ucal_add(UCalendar* cal,
|
||||||
UCalendarDateFields field,
|
UCalendarDateFields field,
|
||||||
int32_t amount,
|
int32_t amount,
|
||||||
UErrorCode* status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a specified signed amount to a particular field in a UCalendar.
|
* Add a specified signed amount to a particular field in a UCalendar.
|
||||||
* This will not modify more significant fields in the calendar.
|
* This will not modify more significant fields in the calendar.
|
||||||
* @param cal The UCalendar to which to add.
|
* @param cal The UCalendar to which to add.
|
||||||
* @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @param amount The signed amount to add to field. If the amount causes the value
|
* @param amount The signed amount to add to field. If the amount causes the value
|
||||||
* to exceed to maximum or minimum values for that field, the field is pinned to a permissible
|
* to exceed to maximum or minimum values for that field, the field is pinned to a permissible
|
||||||
* value.
|
* value.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @see ucal_add
|
* @see ucal_add
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_roll( UCalendar* cal,
|
ucal_roll(UCalendar* cal,
|
||||||
UCalendarDateFields field,
|
UCalendarDateFields field,
|
||||||
int32_t amount,
|
int32_t amount,
|
||||||
UErrorCode* status);
|
UErrorCode* status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current value of a field from a UCalendar.
|
* Get the current value of a field from a UCalendar.
|
||||||
* All fields are represented as 32-bit integers.
|
* All fields are represented as 32-bit integers.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @param status A pointer to an UErrorCode to receive any errors
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
* @return The value of the desired field.
|
* @return The value of the desired field.
|
||||||
* @see ucal_set
|
* @see ucal_set
|
||||||
* @see ucal_isSet
|
* @see ucal_isSet
|
||||||
* @see ucal_clearField
|
* @see ucal_clearField
|
||||||
* @see ucal_clear
|
* @see ucal_clear
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
ucal_get( const UCalendar* cal,
|
ucal_get(const UCalendar* cal,
|
||||||
UCalendarDateFields field,
|
UCalendarDateFields field,
|
||||||
UErrorCode* status );
|
UErrorCode* status );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of a field in a UCalendar.
|
* Set the value of a field in a UCalendar.
|
||||||
* All fields are represented as 32-bit integers.
|
* All fields are represented as 32-bit integers.
|
||||||
* @param cal The UCalendar to set.
|
* @param cal The UCalendar to set.
|
||||||
* @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @param value The desired value of field.
|
* @param value The desired value of field.
|
||||||
* @see ucal_get
|
* @see ucal_get
|
||||||
* @see ucal_isSet
|
* @see ucal_isSet
|
||||||
* @see ucal_clearField
|
* @see ucal_clearField
|
||||||
* @see ucal_clear
|
* @see ucal_clear
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_set( UCalendar* cal,
|
ucal_set(UCalendar* cal,
|
||||||
UCalendarDateFields field,
|
UCalendarDateFields field,
|
||||||
int32_t value);
|
int32_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a field in a UCalendar is set.
|
* Determine if a field in a UCalendar is set.
|
||||||
* All fields are represented as 32-bit integers.
|
* All fields are represented as 32-bit integers.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @return TRUE if field is set, FALSE otherwise.
|
* @return TRUE if field is set, FALSE otherwise.
|
||||||
* @see ucal_get
|
* @see ucal_get
|
||||||
* @see ucal_set
|
* @see ucal_set
|
||||||
* @see ucal_clearField
|
* @see ucal_clearField
|
||||||
* @see ucal_clear
|
* @see ucal_clear
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI UBool U_EXPORT2
|
U_CAPI UBool U_EXPORT2
|
||||||
ucal_isSet( const UCalendar* cal,
|
ucal_isSet(const UCalendar* cal,
|
||||||
UCalendarDateFields field);
|
UCalendarDateFields field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a field in a UCalendar.
|
* Clear a field in a UCalendar.
|
||||||
* All fields are represented as 32-bit integers.
|
* All fields are represented as 32-bit integers.
|
||||||
* @param cal The UCalendar containing the field to clear.
|
* @param cal The UCalendar containing the field to clear.
|
||||||
* @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @see ucal_get
|
* @see ucal_get
|
||||||
* @see ucal_set
|
* @see ucal_set
|
||||||
* @see ucal_isSet
|
* @see ucal_isSet
|
||||||
* @see ucal_clear
|
* @see ucal_clear
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_clearField( UCalendar* cal,
|
ucal_clearField(UCalendar* cal,
|
||||||
UCalendarDateFields field);
|
UCalendarDateFields field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all fields in a UCalendar.
|
* Clear all fields in a UCalendar.
|
||||||
* All fields are represented as 32-bit integers.
|
* All fields are represented as 32-bit integers.
|
||||||
* @param cal The UCalendar to clear.
|
* @param cal The UCalendar to clear.
|
||||||
* @see ucal_get
|
* @see ucal_get
|
||||||
* @see ucal_set
|
* @see ucal_set
|
||||||
* @see ucal_isSet
|
* @see ucal_isSet
|
||||||
* @see ucal_clearField
|
* @see ucal_clearField
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI void U_EXPORT2
|
U_CAPI void U_EXPORT2
|
||||||
ucal_clear(UCalendar* calendar);
|
ucal_clear(UCalendar* calendar);
|
||||||
|
|
||||||
/** Possible limit values for a UCalendar
|
/**
|
||||||
|
* Possible limit values for a UCalendar
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
enum UCalendarLimitType {
|
enum UCalendarLimitType {
|
||||||
@ -737,24 +783,51 @@ enum UCalendarLimitType {
|
|||||||
typedef enum UCalendarLimitType UCalendarLimitType;
|
typedef enum UCalendarLimitType UCalendarLimitType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine a limit for a field in a UCalendar.
|
* Determine a limit for a field in a UCalendar.
|
||||||
* A limit is a maximum or minimum value for a field.
|
* A limit is a maximum or minimum value for a field.
|
||||||
* @param cal The UCalendar to query.
|
* @param cal The UCalendar to query.
|
||||||
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
* @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
|
||||||
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
* UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
|
||||||
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
* UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
|
||||||
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
* UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
|
||||||
* @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,
|
* @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,
|
||||||
* UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
|
* UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
|
||||||
* @param status A pointer to an UErrorCode to receive any errors.
|
* @param status A pointer to an UErrorCode to receive any errors.
|
||||||
* @return The requested value.
|
* @return The requested value.
|
||||||
* @stable ICU 2.0
|
* @stable ICU 2.0
|
||||||
*/
|
*/
|
||||||
U_CAPI int32_t U_EXPORT2
|
U_CAPI int32_t U_EXPORT2
|
||||||
ucal_getLimit( const UCalendar* cal,
|
ucal_getLimit(const UCalendar* cal,
|
||||||
UCalendarDateFields field,
|
UCalendarDateFields field,
|
||||||
UCalendarLimitType type,
|
UCalendarLimitType type,
|
||||||
UErrorCode *status);
|
UErrorCode* status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an available TimeZone ID.
|
||||||
|
* A Timezone ID is a string of the form "America/Los Angeles".
|
||||||
|
* @param rawOffset The desired GMT offset
|
||||||
|
* @param index The index of the desired TimeZone.
|
||||||
|
* @param status A pointer to an UErrorCode to receive any errors
|
||||||
|
* @return The requested TimeZone ID, or 0 if not found
|
||||||
|
* @see ucal_countAvailableTZIDs
|
||||||
|
* @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
|
||||||
|
*/
|
||||||
|
U_CAPI const UChar* U_EXPORT2
|
||||||
|
ucal_getAvailableTZIDs(int32_t rawOffset,
|
||||||
|
int32_t index,
|
||||||
|
UErrorCode* status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine how many TimeZones exist with a certain offset.
|
||||||
|
* This function is most useful as determining the loop ending condition for
|
||||||
|
* calls to \Ref{ucal_getAvailableTZIDs}.
|
||||||
|
* @param rawOffset The desired GMT offset.
|
||||||
|
* @return The number of TimeZones with rawOffset.
|
||||||
|
* @see ucal_getAvailableTZIDs
|
||||||
|
* @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
|
||||||
|
*/
|
||||||
|
U_CAPI int32_t U_EXPORT2
|
||||||
|
ucal_countAvailableTZIDs(int32_t rawOffset);
|
||||||
|
|
||||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||||
|
|
||||||
|
@ -45,11 +45,16 @@ void addCalTest(TestNode** root)
|
|||||||
/* "GMT" */
|
/* "GMT" */
|
||||||
static const UChar fgGMTID [] = { 0x0047, 0x004d, 0x0054, 0x0000 };
|
static const UChar fgGMTID [] = { 0x0047, 0x004d, 0x0054, 0x0000 };
|
||||||
|
|
||||||
|
/* "PST" */
|
||||||
|
static const UChar PST[] = {0x50, 0x53, 0x54, 0x00}; /* "PST" */
|
||||||
|
|
||||||
|
static const UChar EUROPE_PARIS[] = {0x45, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2F, 0x50, 0x61, 0x72, 0x69, 0x73, 0x00}; /* "Europe/Paris" */
|
||||||
|
|
||||||
static void TestCalendar()
|
static void TestCalendar()
|
||||||
{
|
{
|
||||||
UCalendar *caldef = 0, *caldef2 = 0, *calfr = 0, *calit = 0;
|
UCalendar *caldef = 0, *caldef2 = 0, *calfr = 0, *calit = 0;
|
||||||
UEnumeration* uenum = NULL;
|
UEnumeration* uenum = NULL;
|
||||||
int32_t count, count2, offset,i;
|
int32_t count, count2, offset,i,j;
|
||||||
UChar *tzID = 0;
|
UChar *tzID = 0;
|
||||||
UChar *tzdname = 0;
|
UChar *tzdname = 0;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
@ -58,6 +63,7 @@ static void TestCalendar()
|
|||||||
UChar *result = 0;
|
UChar *result = 0;
|
||||||
int32_t resultlength, resultlengthneeded;
|
int32_t resultlength, resultlengthneeded;
|
||||||
char tempMsgBuf[256];
|
char tempMsgBuf[256];
|
||||||
|
UChar zone1[32], zone2[32];
|
||||||
|
|
||||||
/*Testing countAvailableTimeZones*/
|
/*Testing countAvailableTimeZones*/
|
||||||
offset=0;
|
offset=0;
|
||||||
@ -72,53 +78,100 @@ static void TestCalendar()
|
|||||||
for(i=0;i<count;i++){
|
for(i=0;i<count;i++){
|
||||||
ucal_getAvailableTZIDs(offset, i, &status);
|
ucal_getAvailableTZIDs(offset, i, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("FAIL: ucal_getAvailableTZIDs returned %s\n", myErrorName(status));
|
log_err("FAIL: ucal_getAvailableTZIDs returned %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
log_verbose("%s\n", u_austrcpy(tempMsgBuf, ucal_getAvailableTZIDs(offset, i, &status)));
|
log_verbose("%s\n", u_austrcpy(tempMsgBuf, ucal_getAvailableTZIDs(offset, i, &status)));
|
||||||
}
|
}
|
||||||
/*get Illegal TZID where index >= count*/
|
/*get Illegal TZID where index >= count*/
|
||||||
ucal_getAvailableTZIDs(offset, i, &status);
|
ucal_getAvailableTZIDs(offset, i, &status);
|
||||||
if(status != U_INDEX_OUTOFBOUNDS_ERROR){
|
if(status != U_INDEX_OUTOFBOUNDS_ERROR){
|
||||||
log_err("FAIL:for TZID index >= count Expected INDEX_OUTOFBOUNDS_ERROR Got %s\n", myErrorName(status));
|
log_err("FAIL:for TZID index >= count Expected INDEX_OUTOFBOUNDS_ERROR Got %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
status=U_ZERO_ERROR;
|
status=U_ZERO_ERROR;
|
||||||
|
|
||||||
/*Test ucal_openTimeZoneEnumeration*/
|
/*Test ucal_openTimeZones & ucal_openCountryTimeZones*/
|
||||||
offset=0;
|
for (j=0; j<2; ++j) {
|
||||||
uenum = ucal_openTimeZoneEnumeration(offset, &status);
|
const char* api = (j==0) ? "ucal_openTimeZones()" :
|
||||||
if (U_FAILURE(status)) {
|
"ucal_openCountryTimeZones(US)";
|
||||||
log_err("FAIL: ucal_openTimeZoneEnumeration failed with %s",
|
uenum = (j==0) ? ucal_openTimeZones(&status) :
|
||||||
myErrorName(status));
|
ucal_openCountryTimeZones("US", &status);
|
||||||
} else {
|
if (U_FAILURE(status)) {
|
||||||
const char* id;
|
log_err("FAIL: %s failed with %s", api,
|
||||||
int32_t len;
|
u_errorName(status));
|
||||||
count = uenum_count(uenum, &status);
|
} else {
|
||||||
log_verbose("The number of timezone id's present with offset 0 is %d\n", count);
|
const char* id;
|
||||||
if (count < 5) { /* Don't hard code an exact == test here! */
|
int32_t len;
|
||||||
log_err("FAIL: in ucal_openTimeZoneEnumeration, got %d, expected at least 5 for rawOffset 0\n", count);
|
count = uenum_count(uenum, &status);
|
||||||
}
|
log_verbose("%s returned %d timezone id's:\n", api, count);
|
||||||
uenum_reset(uenum, &status);
|
if (count < 5) { /* Don't hard code an exact == test here! */
|
||||||
if (U_FAILURE(status)){
|
log_err("FAIL: in %s, got %d, expected at least 5\n", api, count);
|
||||||
log_err("FAIL: uenum_reset for ucal_openTimeZoneEnumeration returned %s\n",
|
}
|
||||||
myErrorName(status));
|
uenum_reset(uenum, &status);
|
||||||
}
|
|
||||||
for (i=0; i<count; i++) {
|
|
||||||
id = uenum_next(uenum, &len, &status);
|
|
||||||
if (U_FAILURE(status)){
|
if (U_FAILURE(status)){
|
||||||
log_err("FAIL: uenum_next for ucal_openTimeZoneEnumeration returned %s\n",
|
log_err("FAIL: uenum_reset for %s returned %s\n",
|
||||||
myErrorName(status));
|
api, u_errorName(status));
|
||||||
} else {
|
}
|
||||||
log_verbose("%s\n", id);
|
for (i=0; i<count; i++) {
|
||||||
|
id = uenum_next(uenum, &len, &status);
|
||||||
|
if (U_FAILURE(status)){
|
||||||
|
log_err("FAIL: uenum_next for %s returned %s\n",
|
||||||
|
api, u_errorName(status));
|
||||||
|
} else {
|
||||||
|
log_verbose("%s\n", id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Next one should be NULL */
|
||||||
|
id = uenum_next(uenum, &len, &status);
|
||||||
|
if (id != NULL) {
|
||||||
|
log_err("FAIL: uenum_next for %s returned %s, expected NULL\n",
|
||||||
|
api, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Next one should be NULL */
|
uenum_close(uenum);
|
||||||
id = uenum_next(uenum, &len, &status);
|
}
|
||||||
if (id != NULL) {
|
|
||||||
log_err("FAIL: uenum_next for ucal_openTimeZoneEnumeration returned %s, expected NULL\n",
|
/*Test ucal_getDSTSavings*/
|
||||||
id);
|
status = U_ZERO_ERROR;
|
||||||
}
|
i = ucal_getDSTSavings(fgGMTID, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
log_err("FAIL: ucal_getDSTSavings(GMT) => %s\n",
|
||||||
|
u_errorName(status));
|
||||||
|
} else if (i != 0) {
|
||||||
|
log_err("FAIL: ucal_getDSTSavings(GMT) => %d, expect 0\n", i);
|
||||||
|
}
|
||||||
|
i = ucal_getDSTSavings(PST, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
log_err("FAIL: ucal_getDSTSavings(PST) => %s\n",
|
||||||
|
u_errorName(status));
|
||||||
|
} else if (i != 1*60*60*1000) {
|
||||||
|
log_err("FAIL: ucal_getDSTSavings(PST) => %d, expect %d\n", i, 1*60*60*1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Test ucal_set/getDefaultTimeZone*/
|
||||||
|
status = U_ZERO_ERROR;
|
||||||
|
i = ucal_getDefaultTimeZone(zone1, sizeof(zone1)/sizeof(zone1[0]), &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
log_err("FAIL: ucal_getDefaultTimeZone() => %s\n",
|
||||||
|
u_errorName(status));
|
||||||
|
} else {
|
||||||
|
ucal_setDefaultTimeZone(EUROPE_PARIS, &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
log_err("FAIL: ucal_setDefaultTimeZone(Europe/Paris) => %s\n",
|
||||||
|
u_errorName(status));
|
||||||
|
} else {
|
||||||
|
i = ucal_getDefaultTimeZone(zone2, sizeof(zone2)/sizeof(zone2[0]), &status);
|
||||||
|
if (U_FAILURE(status)) {
|
||||||
|
log_err("FAIL: ucal_getDefaultTimeZone() => %s\n",
|
||||||
|
u_errorName(status));
|
||||||
|
} else {
|
||||||
|
if (u_strcmp(zone2, EUROPE_PARIS) != 0) {
|
||||||
|
log_err("FAIL: ucal_getDefaultTimeZone() did not return Europe/Paris\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status = U_ZERO_ERROR;
|
||||||
|
ucal_setDefaultTimeZone(zone1, &status);
|
||||||
}
|
}
|
||||||
uenum_close(uenum);
|
|
||||||
|
|
||||||
/*Testing the ucal_open() function*/
|
/*Testing the ucal_open() function*/
|
||||||
log_verbose("\nTesting the ucal_open()\n");
|
log_verbose("\nTesting the ucal_open()\n");
|
||||||
@ -126,21 +179,21 @@ static void TestCalendar()
|
|||||||
u_uastrcpy(tzID, "PST");
|
u_uastrcpy(tzID, "PST");
|
||||||
caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("FAIL: error in ucal_open caldef : %s\n", myErrorName(status));
|
log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
caldef2=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
caldef2=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("FAIL: error in ucal_open caldef : %s\n", myErrorName(status));
|
log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
u_strcpy(tzID, fgGMTID);
|
u_strcpy(tzID, fgGMTID);
|
||||||
calfr=ucal_open(tzID, u_strlen(tzID), "fr_FR", UCAL_TRADITIONAL, &status);
|
calfr=ucal_open(tzID, u_strlen(tzID), "fr_FR", UCAL_TRADITIONAL, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("FAIL: error in ucal_open calfr : %s\n", myErrorName(status));
|
log_err("FAIL: error in ucal_open calfr : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
calit=ucal_open(tzID, u_strlen(tzID), "it_IT", UCAL_TRADITIONAL, &status);
|
calit=ucal_open(tzID, u_strlen(tzID), "it_IT", UCAL_TRADITIONAL, &status);
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
log_err("FAIL: error in ucal_open calit : %s\n", myErrorName(status));
|
log_err("FAIL: error in ucal_open calit : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -174,7 +227,7 @@ static void TestCalendar()
|
|||||||
/* open the date format and format the date to check the output */
|
/* open the date format and format the date to check the output */
|
||||||
datdef=udat_open(UDAT_FULL,UDAT_FULL ,NULL, NULL, 0,NULL,0,&status);
|
datdef=udat_open(UDAT_FULL,UDAT_FULL ,NULL, NULL, 0,NULL,0,&status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("FAIL: error in creating the dateformat : %s\n", myErrorName(status));
|
log_err("FAIL: error in creating the dateformat : %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_verbose("PASS: The current date and time fetched is %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datdef, now)) );
|
log_verbose("PASS: The current date and time fetched is %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datdef, now)) );
|
||||||
@ -194,7 +247,7 @@ static void TestCalendar()
|
|||||||
ucal_getTimeZoneDisplayName(caldef, UCAL_DST, "en_US", result, resultlength, &status);
|
ucal_getTimeZoneDisplayName(caldef, UCAL_DST, "en_US", result, resultlength, &status);
|
||||||
}
|
}
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
log_err("FAIL: Error in getting the timezone display name : %s\n", myErrorName(status));
|
log_err("FAIL: Error in getting the timezone display name : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
log_verbose("PASS: getting the time zone display name successful : %s, %d needed \n",
|
log_verbose("PASS: getting the time zone display name successful : %s, %d needed \n",
|
||||||
@ -280,7 +333,7 @@ static void TestCalendar()
|
|||||||
ucal_setDateTime(caldef, 1999, UCAL_MARCH, 3, 10, 45, 20, &status);
|
ucal_setDateTime(caldef, 1999, UCAL_MARCH, 3, 10, 45, 20, &status);
|
||||||
ucal_inDaylightTime(caldef, &status );
|
ucal_inDaylightTime(caldef, &status );
|
||||||
if(U_FAILURE(status)) {
|
if(U_FAILURE(status)) {
|
||||||
log_err("Error in ucal_inDaylightTime: %s\n", myErrorName(status));
|
log_err("Error in ucal_inDaylightTime: %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
if(!ucal_inDaylightTime(caldef, &status))
|
if(!ucal_inDaylightTime(caldef, &status))
|
||||||
log_verbose("PASS: It is not in daylight saving's time\n");
|
log_verbose("PASS: It is not in daylight saving's time\n");
|
||||||
@ -330,7 +383,7 @@ static void TestGetSetDateAPI()
|
|||||||
datdef=udat_open(UDAT_DEFAULT,UDAT_DEFAULT ,"en_US",fgGMTID,-1,NULL,0, &status);
|
datdef=udat_open(UDAT_DEFAULT,UDAT_DEFAULT ,"en_US",fgGMTID,-1,NULL,0, &status);
|
||||||
if(U_FAILURE(status))
|
if(U_FAILURE(status))
|
||||||
{
|
{
|
||||||
log_err("error in creating the dateformat : %s\n", myErrorName(status));
|
log_err("error in creating the dateformat : %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,14 +392,14 @@ static void TestGetSetDateAPI()
|
|||||||
log_verbose("\nTesting the date and time fetched in millis for a calendar using getMillis\n");
|
log_verbose("\nTesting the date and time fetched in millis for a calendar using getMillis\n");
|
||||||
d1=ucal_getMillis(caldef, &status);
|
d1=ucal_getMillis(caldef, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in getMillis : %s\n", myErrorName(status));
|
log_err("Error in getMillis : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*testing setMillis */
|
/*testing setMillis */
|
||||||
log_verbose("\nTesting the set date and time function using setMillis\n");
|
log_verbose("\nTesting the set date and time function using setMillis\n");
|
||||||
ucal_setMillis(caldef, d2, &status);
|
ucal_setMillis(caldef, d2, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in setMillis : %s\n", myErrorName(status));
|
log_err("Error in setMillis : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*testing if the calendar date is set properly or not */
|
/*testing if the calendar date is set properly or not */
|
||||||
@ -362,14 +415,14 @@ static void TestGetSetDateAPI()
|
|||||||
log_verbose("\nTesting if the function ucal_setTimeZone() works fine\n");
|
log_verbose("\nTesting if the function ucal_setTimeZone() works fine\n");
|
||||||
ucal_setMillis(caldef2, d2, &status);
|
ucal_setMillis(caldef2, d2, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in getMillis : %s\n", myErrorName(status));;
|
log_err("Error in getMillis : %s\n", u_errorName(status));;
|
||||||
}
|
}
|
||||||
hour=ucal_get(caldef2, UCAL_HOUR_OF_DAY, &status);
|
hour=ucal_get(caldef2, UCAL_HOUR_OF_DAY, &status);
|
||||||
|
|
||||||
u_uastrcpy(tzID, "PST");
|
u_uastrcpy(tzID, "PST");
|
||||||
ucal_setTimeZone(caldef2,tzID, 3, &status);
|
ucal_setTimeZone(caldef2,tzID, 3, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", myErrorName(status));
|
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log_verbose("ucal_setTimeZone worked fine\n");
|
log_verbose("ucal_setTimeZone worked fine\n");
|
||||||
@ -385,7 +438,7 @@ static void TestGetSetDateAPI()
|
|||||||
u_strcpy(tzID, fgGMTID);
|
u_strcpy(tzID, fgGMTID);
|
||||||
ucal_setTimeZone(caldef2, tzID, 3, &status);
|
ucal_setTimeZone(caldef2, tzID, 3, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", myErrorName(status));
|
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
if(d2==ucal_getMillis(caldef2, &status))
|
if(d2==ucal_getMillis(caldef2, &status))
|
||||||
log_verbose("PASS: setTimeZone roundtrip test passed\n");
|
log_verbose("PASS: setTimeZone roundtrip test passed\n");
|
||||||
@ -394,7 +447,7 @@ static void TestGetSetDateAPI()
|
|||||||
|
|
||||||
zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status);
|
zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", myErrorName(status));
|
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
else if (zoneOffset != 0) {
|
else if (zoneOffset != 0) {
|
||||||
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset);
|
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset);
|
||||||
@ -402,7 +455,7 @@ static void TestGetSetDateAPI()
|
|||||||
|
|
||||||
ucal_setTimeZone(caldef2, NULL, -1, &status);
|
ucal_setTimeZone(caldef2, NULL, -1, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", myErrorName(status));
|
log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
if(ucal_getMillis(caldef2, &status))
|
if(ucal_getMillis(caldef2, &status))
|
||||||
log_verbose("PASS: setTimeZone roundtrip test passed\n");
|
log_verbose("PASS: setTimeZone roundtrip test passed\n");
|
||||||
@ -411,7 +464,7 @@ static void TestGetSetDateAPI()
|
|||||||
|
|
||||||
zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status);
|
zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", myErrorName(status));
|
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
else if (zoneOffset != -28800000) {
|
else if (zoneOffset != -28800000) {
|
||||||
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset);
|
log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset);
|
||||||
@ -425,7 +478,7 @@ static void TestGetSetDateAPI()
|
|||||||
u_uastrcpy(temp, "Dec 17, 1971 11:05:28 PM");
|
u_uastrcpy(temp, "Dec 17, 1971 11:05:28 PM");
|
||||||
ucal_setDate(caldef,1971, UCAL_DECEMBER, 17, &status);
|
ucal_setDate(caldef,1971, UCAL_DECEMBER, 17, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error in setting the calendar date : %s\n", myErrorName(status));
|
log_err("error in setting the calendar date : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
/*checking if the calendar date is set properly or not */
|
/*checking if the calendar date is set properly or not */
|
||||||
d1=ucal_getMillis(caldef, &status);
|
d1=ucal_getMillis(caldef, &status);
|
||||||
@ -456,7 +509,7 @@ static void TestGetSetDateAPI()
|
|||||||
u_uastrcpy(temp, "May 3, 1972 4:30:42 PM");
|
u_uastrcpy(temp, "May 3, 1972 4:30:42 PM");
|
||||||
ucal_setDateTime(caldef,1972, UCAL_MAY, 3, 16, 30, 42, &status);
|
ucal_setDateTime(caldef,1972, UCAL_MAY, 3, 16, 30, 42, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error in setting the calendar date : %s\n", myErrorName(status));
|
log_err("error in setting the calendar date : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
/*checking if the calendar date is set properly or not */
|
/*checking if the calendar date is set properly or not */
|
||||||
d1=ucal_getMillis(caldef, &status);
|
d1=ucal_getMillis(caldef, &status);
|
||||||
@ -509,20 +562,20 @@ static void TestFieldGetSet()
|
|||||||
/*open the calendar used */
|
/*open the calendar used */
|
||||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open failed: %s\n", myErrorName(status));
|
log_err("ucal_open failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
datdef=udat_open(UDAT_SHORT,UDAT_SHORT ,NULL,fgGMTID,-1,NULL, 0, &status);
|
datdef=udat_open(UDAT_SHORT,UDAT_SHORT ,NULL,fgGMTID,-1,NULL, 0, &status);
|
||||||
if(U_FAILURE(status))
|
if(U_FAILURE(status))
|
||||||
{
|
{
|
||||||
log_err("error in creating the dateformat : %s\n", myErrorName(status));
|
log_err("error in creating the dateformat : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Testing ucal_get()*/
|
/*Testing ucal_get()*/
|
||||||
log_verbose("\nTesting the ucal_get() function of Calendar\n");
|
log_verbose("\nTesting the ucal_get() function of Calendar\n");
|
||||||
ucal_setDateTime(cal, 1999, UCAL_MARCH, 12, 5, 25, 30, &status);
|
ucal_setDateTime(cal, 1999, UCAL_MARCH, 12, 5, 25, 30, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error in the setDateTime() : %s\n", myErrorName(status));
|
log_err("error in the setDateTime() : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
if(ucal_get(cal, UCAL_YEAR, &status)!=1999 || ucal_get(cal, UCAL_MONTH, &status)!=2 ||
|
if(ucal_get(cal, UCAL_YEAR, &status)!=1999 || ucal_get(cal, UCAL_MONTH, &status)!=2 ||
|
||||||
ucal_get(cal, UCAL_DATE, &status)!=12 || ucal_get(cal, UCAL_HOUR, &status)!=5)
|
ucal_get(cal, UCAL_DATE, &status)!=12 || ucal_get(cal, UCAL_HOUR, &status)!=5)
|
||||||
@ -658,7 +711,7 @@ static void TestAddRollExtensive()
|
|||||||
/*open the calendar used */
|
/*open the calendar used */
|
||||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open() failed : %s\n", myErrorName(status));
|
log_err("ucal_open() failed : %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,30 +723,30 @@ static void TestAddRollExtensive()
|
|||||||
log_verbose("\nTesting to confirm that adding to various fields works with ucal_add()\n");
|
log_verbose("\nTesting to confirm that adding to various fields works with ucal_add()\n");
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal,UCAL_YEAR, 1, &status);
|
ucal_add(cal,UCAL_YEAR, 1, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", myErrorName(status)); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status)); return; }
|
||||||
y++;
|
y++;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal,UCAL_MONTH, 12, &status);
|
ucal_add(cal,UCAL_MONTH, 12, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; }
|
||||||
y+=1;
|
y+=1;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal,UCAL_DATE, 1, &status);
|
ucal_add(cal,UCAL_DATE, 1, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; }
|
||||||
d++;
|
d++;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal,UCAL_DATE, 2, &status);
|
ucal_add(cal,UCAL_DATE, 2, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; }
|
||||||
d += 2;
|
d += 2;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal,UCAL_DATE, 28, &status);
|
ucal_add(cal,UCAL_DATE, 28, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; }
|
||||||
++m;
|
++m;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_add(cal, (UCalendarDateFields)-1, 10, &status);
|
ucal_add(cal, (UCalendarDateFields)-1, 10, &status);
|
||||||
if(status==U_ILLEGAL_ARGUMENT_ERROR)
|
if(status==U_ILLEGAL_ARGUMENT_ERROR)
|
||||||
log_verbose("Pass: Illegal argument error as expected\n");
|
log_verbose("Pass: Illegal argument error as expected\n");
|
||||||
else{
|
else{
|
||||||
log_err("Fail: No, illegal argument error as expected. Got....: %s\n", myErrorName(status));
|
log_err("Fail: No, illegal argument error as expected. Got....: %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
status=U_ZERO_ERROR;
|
status=U_ZERO_ERROR;
|
||||||
|
|
||||||
@ -701,39 +754,39 @@ static void TestAddRollExtensive()
|
|||||||
/*confirm that applying roll to various fields works fine*/
|
/*confirm that applying roll to various fields works fine*/
|
||||||
log_verbose("\nTesting to confirm that ucal_roll() works\n");
|
log_verbose("\nTesting to confirm that ucal_roll() works\n");
|
||||||
ucal_roll(cal, UCAL_DATE, -1, &status);
|
ucal_roll(cal, UCAL_DATE, -1, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
d -=1;
|
d -=1;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, UCAL_MONTH, -2, &status);
|
ucal_roll(cal, UCAL_MONTH, -2, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
m -=2;
|
m -=2;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, UCAL_DATE, 1, &status);
|
ucal_roll(cal, UCAL_DATE, 1, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
d +=1;
|
d +=1;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, UCAL_MONTH, -12, &status);
|
ucal_roll(cal, UCAL_MONTH, -12, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, UCAL_YEAR, -1, &status);
|
ucal_roll(cal, UCAL_YEAR, -1, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
y -=1;
|
y -=1;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, UCAL_DATE, 29, &status);
|
ucal_roll(cal, UCAL_DATE, 29, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; }
|
||||||
d = 2;
|
d = 2;
|
||||||
checkDate(cal, y, m, d);
|
checkDate(cal, y, m, d);
|
||||||
ucal_roll(cal, (UCalendarDateFields)-1, 10, &status);
|
ucal_roll(cal, (UCalendarDateFields)-1, 10, &status);
|
||||||
if(status==U_ILLEGAL_ARGUMENT_ERROR)
|
if(status==U_ILLEGAL_ARGUMENT_ERROR)
|
||||||
log_verbose("Pass: illegal arguement error as expected\n");
|
log_verbose("Pass: illegal arguement error as expected\n");
|
||||||
else{
|
else{
|
||||||
log_err("Fail: no illegal argument error got..: %s\n", myErrorName(status));
|
log_err("Fail: no illegal argument error got..: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
status=U_ZERO_ERROR;
|
status=U_ZERO_ERROR;
|
||||||
ucal_setDateTime(cal, 1999, UCAL_FEBRUARY, 28, 10, 30, 45, &status);
|
ucal_setDateTime(cal, 1999, UCAL_FEBRUARY, 28, 10, 30, 45, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error is setting the datetime: %s\n", myErrorName(status));
|
log_err("error is setting the datetime: %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
ucal_add(cal, UCAL_MONTH, 1, &status);
|
ucal_add(cal, UCAL_MONTH, 1, &status);
|
||||||
checkDate(cal, 1999, UCAL_MARCH, 28);
|
checkDate(cal, 1999, UCAL_MARCH, 28);
|
||||||
@ -748,7 +801,7 @@ static void TestAddRollExtensive()
|
|||||||
y = 1997; m = UCAL_FEBRUARY; d = 1; hr = 1; min = 1; sec = 0; ms = 0;
|
y = 1997; m = UCAL_FEBRUARY; d = 1; hr = 1; min = 1; sec = 0; ms = 0;
|
||||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open failed: %s\n", myErrorName(status));
|
log_err("ucal_open failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ucal_set(cal, UCAL_YEAR, y);
|
ucal_set(cal, UCAL_YEAR, y);
|
||||||
@ -771,7 +824,7 @@ static void TestAddRollExtensive()
|
|||||||
for (i = 0; i < limit; i++) {
|
for (i = 0; i < limit; i++) {
|
||||||
ucal_add(cal, e, -1, &status);
|
ucal_add(cal, e, -1, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_add -1 failed: %s\n", myErrorName(status));
|
log_err("ucal_add -1 failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -791,7 +844,7 @@ static void TestAddRollExtensive()
|
|||||||
for (i = 0; i < limit; i++) {
|
for (i = 0; i < limit; i++) {
|
||||||
ucal_roll(cal, e, -1, &status);
|
ucal_roll(cal, e, -1, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_roll -1 failed: %s\n", myErrorName(status));
|
log_err("ucal_roll -1 failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -817,7 +870,7 @@ static void TestGetLimits()
|
|||||||
/*open the calendar used */
|
/*open the calendar used */
|
||||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);;
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open() for gregorian calendar failed in TestGetLimits: %s\n", myErrorName(status));
|
log_err("ucal_open() for gregorian calendar failed in TestGetLimits: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +909,7 @@ static void TestGetLimits()
|
|||||||
ac_min=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MINIMUM, &status);
|
ac_min=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MINIMUM, &status);
|
||||||
ac_max=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MAXIMUM, &status);
|
ac_max=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MAXIMUM, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("Error in getLimits: %s\n", myErrorName(status));
|
log_err("Error in getLimits: %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
if(min!=0 || max!=11 || gr_min!=0 || le_max!=11 || ac_min!=0 || ac_max!=11)
|
if(min!=0 || max!=11 || gr_min!=0 || le_max!=11 || ac_min!=0 || ac_max!=11)
|
||||||
log_err("There is and error in getLimits in fetching the values\n");
|
log_err("There is and error in getLimits in fetching the values\n");
|
||||||
@ -917,13 +970,13 @@ static void TestDOWProgression()
|
|||||||
/*open the calendar used */
|
/*open the calendar used */
|
||||||
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);;
|
cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);;
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open failed: %s\n", myErrorName(status));
|
log_err("ucal_open failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status);
|
datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error in creating the dateformat : %s\n", myErrorName(status));
|
log_err("error in creating the dateformat : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -932,23 +985,23 @@ static void TestDOWProgression()
|
|||||||
log_verbose("\nTesting the DOW progression\n");
|
log_verbose("\nTesting the DOW progression\n");
|
||||||
|
|
||||||
initialDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
|
initialDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", myErrorName(status) ); return; }
|
if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", u_errorName(status) ); return; }
|
||||||
newDOW = initialDOW;
|
newDOW = initialDOW;
|
||||||
do {
|
do {
|
||||||
DOW = newDOW;
|
DOW = newDOW;
|
||||||
log_verbose("DOW = %d...\n", DOW);
|
log_verbose("DOW = %d...\n", DOW);
|
||||||
date1=ucal_getMillis(cal, &status);
|
date1=ucal_getMillis(cal, &status);
|
||||||
if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", myErrorName(status)); return;}
|
if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", u_errorName(status)); return;}
|
||||||
log_verbose("%s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)));
|
log_verbose("%s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)));
|
||||||
|
|
||||||
ucal_add(cal,UCAL_DAY_OF_WEEK, delta, &status);
|
ucal_add(cal,UCAL_DAY_OF_WEEK, delta, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_add() failed: %s\n", myErrorName(status)); return; }
|
if (U_FAILURE(status)) { log_err("ucal_add() failed: %s\n", u_errorName(status)); return; }
|
||||||
|
|
||||||
newDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
|
newDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
|
||||||
if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", myErrorName(status)); return; }
|
if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", u_errorName(status)); return; }
|
||||||
expectedDOW = 1 + (DOW + delta - 1) % 7;
|
expectedDOW = 1 + (DOW + delta - 1) % 7;
|
||||||
date1=ucal_getMillis(cal, &status);
|
date1=ucal_getMillis(cal, &status);
|
||||||
if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", myErrorName(status)); return;}
|
if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", u_errorName(status)); return;}
|
||||||
if (newDOW != expectedDOW) {
|
if (newDOW != expectedDOW) {
|
||||||
log_err("Day of week should be %d instead of %d on %s", expectedDOW, newDOW,
|
log_err("Day of week should be %d instead of %d on %s", expectedDOW, newDOW,
|
||||||
u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) );
|
u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) );
|
||||||
@ -993,30 +1046,30 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||||||
u_strcpy(tzID, fgGMTID);
|
u_strcpy(tzID, fgGMTID);
|
||||||
gmtcal=ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);;
|
gmtcal=ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);;
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open failed: %s\n", myErrorName(status));
|
log_err("ucal_open failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
u_uastrcpy(tzID, "PST");
|
u_uastrcpy(tzID, "PST");
|
||||||
cal = ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);
|
cal = ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_open failed: %s\n", myErrorName(status));
|
log_err("ucal_open failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status);
|
datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status);
|
||||||
if(U_FAILURE(status)){
|
if(U_FAILURE(status)){
|
||||||
log_err("error in creating the dateformat : %s\n", myErrorName(status));
|
log_err("error in creating the dateformat : %s\n", u_errorName(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
ucal_setDateTime(gmtcal, yr, mo - 1, dt, hr, mn, sc, &status);
|
ucal_setDateTime(gmtcal, yr, mo - 1, dt, hr, mn, sc, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_setDateTime failed: %s\n", myErrorName(status));
|
log_err("ucal_setDateTime failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ucal_set(gmtcal, UCAL_MILLISECOND, 0);
|
ucal_set(gmtcal, UCAL_MILLISECOND, 0);
|
||||||
date1 = ucal_getMillis(gmtcal, &status);
|
date1 = ucal_getMillis(gmtcal, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_getMillis failed: %s\n", myErrorName(status));
|
log_err("ucal_getMillis failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_verbose("date = %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) );
|
log_verbose("date = %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) );
|
||||||
@ -1024,7 +1077,7 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||||||
|
|
||||||
ucal_setMillis(cal, date1, &status);
|
ucal_setMillis(cal, date1, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_setMillis() failed: %s\n", myErrorName(status));
|
log_err("ucal_setMillis() failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,7 +1085,7 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||||||
offset += ucal_get(cal, UCAL_DST_OFFSET, &status);
|
offset += ucal_get(cal, UCAL_DST_OFFSET, &status);
|
||||||
|
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_get() failed: %s\n", myErrorName(status));
|
log_err("ucal_get() failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
temp=(double)((double)offset / 1000.0 / 60.0 / 60.0);
|
temp=(double)((double)offset / 1000.0 / 60.0 / 60.0);
|
||||||
@ -1043,7 +1096,7 @@ static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn
|
|||||||
ucal_get(cal, UCAL_SECOND, &status)) * 1000 +
|
ucal_get(cal, UCAL_SECOND, &status)) * 1000 +
|
||||||
ucal_get(cal, UCAL_MILLISECOND, &status) - offset;
|
ucal_get(cal, UCAL_MILLISECOND, &status) - offset;
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_get() failed: %s\n", myErrorName(status));
|
log_err("ucal_get() failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1094,7 +1147,7 @@ static void checkDateTime(UCalendar* c,
|
|||||||
ucal_get(c, UCAL_MILLISECOND, &status) );
|
ucal_get(c, UCAL_MILLISECOND, &status) );
|
||||||
|
|
||||||
if (U_FAILURE(status)){
|
if (U_FAILURE(status)){
|
||||||
log_err("ucal_get failed: %s\n", myErrorName(status));
|
log_err("ucal_get failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,7 +1171,7 @@ static void checkDate(UCalendar* c, int32_t y, int32_t m, int32_t d)
|
|||||||
ucal_get(c, UCAL_DATE, &status) );
|
ucal_get(c, UCAL_DATE, &status) );
|
||||||
|
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_get failed: %s\n", myErrorName(status));
|
log_err("ucal_get failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1140,13 +1193,13 @@ static void verify1(const char* msg, UCalendar* c, UDateFormat* dat, int32_t yea
|
|||||||
ucal_get(c, UCAL_MONTH, &status) == month &&
|
ucal_get(c, UCAL_MONTH, &status) == month &&
|
||||||
ucal_get(c, UCAL_DATE, &status) == day) {
|
ucal_get(c, UCAL_DATE, &status) == day) {
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("FAIL: Calendar::get failed: %s\n", myErrorName(status));
|
log_err("FAIL: Calendar::get failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_verbose("PASS: %s\n", msg);
|
log_verbose("PASS: %s\n", msg);
|
||||||
d1=ucal_getMillis(c, &status);
|
d1=ucal_getMillis(c, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_getMillis failed: %s\n", myErrorName(status));
|
log_err("ucal_getMillis failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*log_verbose(austrdup(myDateFormat(dat, d1)) );*/
|
/*log_verbose(austrdup(myDateFormat(dat, d1)) );*/
|
||||||
@ -1155,7 +1208,7 @@ static void verify1(const char* msg, UCalendar* c, UDateFormat* dat, int32_t yea
|
|||||||
log_err("FAIL: %s\n", msg);
|
log_err("FAIL: %s\n", msg);
|
||||||
d1=ucal_getMillis(c, &status);
|
d1=ucal_getMillis(c, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_getMillis failed: %s\n", myErrorName(status) );
|
log_err("ucal_getMillis failed: %s\n", u_errorName(status) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_err("Got %s Expected %d/%d/%d \n", austrdup(myDateFormat(dat, d1)), year, month + 1, day );
|
log_err("Got %s Expected %d/%d/%d \n", austrdup(myDateFormat(dat, d1)), year, month + 1, day );
|
||||||
@ -1181,13 +1234,13 @@ static void verify2(const char* msg, UCalendar* c, UDateFormat* dat, int32_t yea
|
|||||||
ucal_get(c, UCAL_SECOND, &status) == sec &&
|
ucal_get(c, UCAL_SECOND, &status) == sec &&
|
||||||
ucal_get(c, UCAL_AM_PM, &status) == am_pm ){
|
ucal_get(c, UCAL_AM_PM, &status) == am_pm ){
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("FAIL: Calendar::get failed: %s\n", myErrorName(status));
|
log_err("FAIL: Calendar::get failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_verbose("PASS: %s\n", msg);
|
log_verbose("PASS: %s\n", msg);
|
||||||
d1=ucal_getMillis(c, &status);
|
d1=ucal_getMillis(c, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_getMillis failed: %s\n", myErrorName(status));
|
log_err("ucal_getMillis failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_verbose("%s\n" , u_austrcpy(tempMsgBuf, myDateFormat(dat, d1)) );
|
log_verbose("%s\n" , u_austrcpy(tempMsgBuf, myDateFormat(dat, d1)) );
|
||||||
@ -1196,7 +1249,7 @@ static void verify2(const char* msg, UCalendar* c, UDateFormat* dat, int32_t yea
|
|||||||
log_err("FAIL: %s\n", msg);
|
log_err("FAIL: %s\n", msg);
|
||||||
d1=ucal_getMillis(c, &status);
|
d1=ucal_getMillis(c, &status);
|
||||||
if (U_FAILURE(status)) {
|
if (U_FAILURE(status)) {
|
||||||
log_err("ucal_getMillis failed: %s\n", myErrorName(status));
|
log_err("ucal_getMillis failed: %s\n", u_errorName(status));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log_err("Got %s Expected %d/%d/%d/ %d:%d:%d %s\n", austrdup(myDateFormat(dat, d1)),
|
log_err("Got %s Expected %d/%d/%d/ %d:%d:%d %s\n", austrdup(myDateFormat(dat, d1)),
|
||||||
|
Loading…
Reference in New Issue
Block a user