Example #1
0
int32_t JapaneseCalendar::getDefaultDayInMonth(int32_t month) 
{
  UErrorCode status  = U_ZERO_ERROR;
  int32_t era = internalGetEra();
  computeFields(status); // slow
  int32_t year = getGregorianYear();
  int32_t day = GregorianCalendar::getDefaultDayInMonth(month);
  
  if(year == kEraInfo[era].year) {
    if(month == (kEraInfo[era].month-1)) {
      return kEraInfo[era].day;
    }
  }

  return day;
}
Example #2
0
/**
 * Sets this Calendar's current time from the given long value.
 * @param date the new time in UTC milliseconds from the epoch.
 */
void 
Calendar::setTimeInMillis( double millis, UErrorCode& status ) {
    if(U_FAILURE(status)) 
        return;

    fIsTimeSet = TRUE;
    fTime = millis;

    fAreFieldsSet = FALSE;

    computeFields(status);

    /* Test for buffer overflows */
    if(U_FAILURE(status)) {
        return;
    }
    fAreFieldsSet = TRUE;
    fAreAllFieldsSet = TRUE;
}
Example #3
0
int32_t JapaneseCalendar::getDefaultMonthInYear() 
{
  UErrorCode status  = U_ZERO_ERROR;
  int32_t era = internalGetEra();
  computeFields(status); // slow
  int32_t year = getGregorianYear();
  // TODO do we assume we can trust 'era'?  What if it is denormalized?

  int32_t month = GregorianCalendar::getDefaultMonthInYear();

  // Find out if we are at the edge of an era

  if(year == kEraInfo[era].year) {
    // Yes, we're in the first year of this era.
    return kEraInfo[era].month-1;
  }

  return month;
}
Example #4
0
void
Calendar::complete(UErrorCode& status)
{
    if (!fIsTimeSet) {
        updateTime(status);
        /* Test for buffer overflows */
        if(U_FAILURE(status)) {
            return;
        }
    }
    if (!fAreFieldsSet) {
        computeFields(status); // fills in unset fields
        /* Test for buffer overflows */
        if(U_FAILURE(status)) {
            return;
        }
        fAreFieldsSet         = TRUE;
        fAreAllFieldsSet     = TRUE;
    }
}