/*
*******************************************************************************
-* Copyright (C) 1997-2014, International Business Machines Corporation and *
+* Copyright (C) 1997-2015, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
#if !UCONFIG_NO_FORMATTING
-#include "unicode/uchar.h"
#include "unicode/gregocal.h"
#include "unicode/basictz.h"
#include "unicode/simpletz.h"
{ -0x7F000000, -0x7F000000, 0x7F000000, 0x7F000000 }, // JULIAN_DAY
{ 0, 0, 24*kOneHour-1, 24*kOneHour-1 }, // MILLISECONDS_IN_DAY
{ 0, 0, 1, 1 }, // IS_LEAP_MONTH
- { UCHAR_MIN_VALUE, UCHAR_MIN_VALUE, UCHAR_MAX_VALUE, UCHAR_MAX_VALUE }, // TIME_SEPARATOR
};
// Resource bundle tags read by this class
case UCAL_JULIAN_DAY:
case UCAL_MILLISECONDS_IN_DAY:
case UCAL_IS_LEAP_MONTH:
- case UCAL_TIME_SEPARATOR:
return kCalendarLimits[field][limitType];
case UCAL_WEEK_OF_MONTH:
/*
*******************************************************************************
-* Copyright (C) 1997-2014, International Business Machines Corporation and
+* Copyright (C) 1997-2015, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
{/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
- {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // TIME_SEPARATOR
};
/*
UDAT_HOUR0_FIELD,
UDAT_MILLISECONDS_IN_DAY_FIELD,
UDAT_TIMEZONE_RFC_FIELD,
- UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD,
- UDAT_TIME_SEPARATOR_FIELD };
-static const int8_t kTimeFieldsCount = 11;
+ UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD };
+static const int8_t kTimeFieldsCount = 10;
// This is a pattern-of-last-resort used when we can't load a usable pattern out
/*sS*/ 70, 80,
/*z?Y*/ 0, 0, 10,
/*eug*/ 30, 10, 0,
- /*A?.*/ 40, 0, 0,
- /*:*/ 0
+ /*A?.*/ 40, 0, 0
};
int32_t SimpleDateFormat::getLevelFromChar(UChar ch) {
- // Map calendar field LETTER into calendar field level.
+ // Map date field LETTER into calendar field level.
// the larger the level, the smaller the field unit.
// NOTE: if new fields adds in, the table needs to update.
static const int32_t mapCharToLevel[] = {
/*O*/ UCAL_ZONE_OFFSET,
/*Xx*/ UCAL_ZONE_OFFSET, UCAL_ZONE_OFFSET,
/*r*/ UCAL_EXTENDED_YEAR,
- /*:*/ UCAL_TIME_SEPARATOR,
+ /*:*/ UCAL_FIELD_COUNT, /* => no useful mapping to any calendar field */
};
// Map index into pattern character string to DateFormat field number
}
UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
- int32_t value = (patternCharIndex != UDAT_RELATED_YEAR_FIELD)? cal.get(field, status): cal.getRelatedYear(status);
+ int32_t value = 0;
+ // Don't get value unless it is useful
+ if (field < UCAL_FIELD_COUNT) {
+ value = (patternCharIndex != UDAT_RELATED_YEAR_FIELD)? cal.get(field, status): cal.getRelatedYear(status);
+ }
if (U_FAILURE(status)) {
return;
}
}
if (bestMatch >= 0) {
- // Adjustment for Hebrew Calendar month Adar II
- if (!strcmp(cal.getType(),"hebrew") && field==UCAL_MONTH && bestMatch==13) {
- cal.set(field,6);
- } else {
- if (field == UCAL_YEAR) {
- bestMatch++; // only get here for cyclic year names, which match 1-based years 1-60
+ if (field < UCAL_FIELD_COUNT) {
+ // Adjustment for Hebrew Calendar month Adar II
+ if (!strcmp(cal.getType(),"hebrew") && field==UCAL_MONTH && bestMatch==13) {
+ cal.set(field,6);
+ } else {
+ if (field == UCAL_YEAR) {
+ bestMatch++; // only get here for cyclic year names, which match 1-based years 1-60
+ }
+ cal.set(field, bestMatch);
+ }
+ if (monthPattern != NULL) {
+ cal.set(UCAL_IS_LEAP_MONTH, isLeapMonth);
}
- cal.set(field, bestMatch);
- }
- if (monthPattern != NULL) {
- cal.set(UCAL_IS_LEAP_MONTH, isLeapMonth);
}
return start + bestMatchLength;
if (currentNumberFormat == NULL) {
return -start;
}
- UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex];
+ UCalendarDateFields field = fgPatternIndexToCalendarField[patternCharIndex]; // UCAL_FIELD_COUNT if irrelevant
UnicodeString hebr("hebr", 4, US_INV);
if (numericLeapMonthFormatter != NULL) {
data[count++].setTo(alt_sep);
}
- return matchString(text, start, UCAL_TIME_SEPARATOR, data, count, NULL, cal);
+ return matchString(text, start, UCAL_FIELD_COUNT /* => nothing to set */, data, count, NULL, cal);
}
default:
*/
UCAL_IS_LEAP_MONTH,
-#ifndef U_HIDE_DRAFT_API
- /**
- * Field number indicating the separator between
- * <code>HOUR</code>, <code>MINUTE</code> and <code>SECOND</code>.
- * E.g., at 10:04 the <code>TIME_SEPARATOR</code> is <code>:</code>.
- * @see #UCAL_HOUR
- * @see #UCAL_MINUTE
- * @see #UCAL_SECOND
- * @draft ICU 55
- */
- UCAL_TIME_SEPARATOR,
-#else
- UCAL_TIME_SEPARATOR_HIDE_DRAFT_API,
-#endif /* U_HIDE_DRAFT_API */
-
/**
* Field count
* @stable ICU 2.6
#ifndef U_HIDE_DRAFT_API
/**
* FieldPosition and UFieldPosition selector for ':' time separator,
- * corresponding to the UCAL_TIME_SEPARATOR field.
+ * no corresponding UCAL_ field.
* @draft ICU 55
*/
UDAT_TIME_SEPARATOR_FIELD = 35,
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2007-2014, International Business Machines Corporation and
+ * Copyright (c) 2007-2015, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
FIELD_NAME_STR( LEN_UCAL, UCAL_JULIAN_DAY ),
FIELD_NAME_STR( LEN_UCAL, UCAL_MILLISECONDS_IN_DAY ),
FIELD_NAME_STR( LEN_UCAL, UCAL_IS_LEAP_MONTH ),
- FIELD_NAME_STR( LEN_UCAL, UCAL_TIME_SEPARATOR ),
};