/*
******************************************************************************
- * Copyright (C) 2003-2008, International Business Machines Corporation
+ * Copyright (C) 2003-2012, International Business Machines Corporation
* and others. All Rights Reserved.
******************************************************************************
*
static void julian_to_jalali (int32_t daysNo, int *h_y, int *h_m, int *h_d)
{
- int year=0, month=0, day=0,scalarDays=0;
+ int year=0, month=0, day=0;
int i;
daysNo+=856493;
- scalarDays=daysNo;
year=(daysNo/1029983)*2820;
daysNo=daysNo%1029983;
// initialize systemDefaultCentury and systemDefaultCenturyYear based
// on the current time. They'll be set to 80 years before
// the current time.
- // No point in locking as it should be idempotent.
- if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
+ UErrorCode status = U_ZERO_ERROR;
+ PersianCalendar calendar(Locale("@calendar=persian"),status);
+ if (U_SUCCESS(status))
{
- UErrorCode status = U_ZERO_ERROR;
- PersianCalendar calendar(Locale("@calendar=persian"),status);
- if (U_SUCCESS(status))
+ calendar.setTime(Calendar::getNow(), status);
+ calendar.add(UCAL_YEAR, -80, status);
+ UDate newStart = calendar.getTime(status);
+ int32_t newYear = calendar.get(UCAL_YEAR, status);
+ umtx_lock(NULL);
+ if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
{
- calendar.setTime(Calendar::getNow(), status);
- calendar.add(UCAL_YEAR, -80, status);
- UDate newStart = calendar.getTime(status);
- int32_t newYear = calendar.get(UCAL_YEAR, status);
- {
- umtx_lock(NULL);
- fgSystemDefaultCenturyStart = newStart;
- fgSystemDefaultCenturyStartYear = newYear;
- umtx_unlock(NULL);
- }
+ fgSystemDefaultCenturyStartYear = newYear;
+ fgSystemDefaultCenturyStart = newStart;
}
- // We have no recourse upon failure unless we want to propagate the failure
- // out.
+ umtx_unlock(NULL);
}
+ // We have no recourse upon failure unless we want to propagate the failure
+ // out.
}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PersianCalendar)