chromium/third_party/icu/source/i18n/timezone.cpp

// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1997-2016, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
* File TIMEZONE.CPP
*
* Modification History:
*
*   Date        Name        Description
*   12/05/96    clhuang     Creation.
*   04/21/97    aliu        General clean-up and bug fixing.
*   05/08/97    aliu        Fixed Hashtable code per code review.
*   07/09/97    helena      Changed createInstance to createDefault.
*   07/29/97    aliu        Updated with all-new list of 96 UNIX-derived
*                           TimeZones.  Changed mechanism to load from static
*                           array rather than resource bundle.
*   07/07/1998  srl         Bugfixes from the Java side: UTC GMT CAT NST
*                           Added getDisplayName API
*                           going to add custom parsing.
*
*                           ISSUES:
*                               - should getDisplayName cache something?
*                               - should custom time zones be cached? [probably]
*  08/10/98     stephen     Brought getDisplayName() API in-line w/ conventions
*  08/19/98     stephen     Changed createTimeZone() to never return 0
*  09/02/98     stephen     Added getOffset(monthLen) and hasSameRules()
*  09/15/98     stephen     Added getStaticClassID()
*  02/22/99     stephen     Removed character literals for EBCDIC safety
*  05/04/99     stephen     Changed initDefault() for Mutex issues
*  07/12/99     helena      HPUX 11 CC Port.
*  12/03/99     aliu        Moved data out of static table into icudata.dll.
*                           Substantial rewrite of zone lookup, default zone, and
*                           available IDs code.  Misc. cleanup.
*********************************************************************************/

#include "utypeinfo.h"  // for 'typeid' to work

#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "uassert.h"
#include "ustr_imp.h"

#ifdef U_DEBUG_TZ
# include <stdio.h>
# include "uresimp.h" // for debugging

static void debug_tz_loc(const char *f, int32_t l)
{
  fprintf(stderr, "%s:%d: ", f, l);
}

static void debug_tz_msg(const char *pat, ...)
{
  va_list ap;
  va_start(ap, pat);
  vfprintf(stderr, pat, ap);
  fflush(stderr);
}
static char gStrBuf[256];
#define U_DEBUG_TZ_STR
// must use double parens, i.e.:  U_DEBUG_TZ_MSG(("four is: %d",4));
#define U_DEBUG_TZ_MSG
#else
#define U_DEBUG_TZ_MSG(x)
#endif

#if !UCONFIG_NO_FORMATTING

#include "unicode/simpletz.h"
#include "unicode/calendar.h"
#include "unicode/gregocal.h"
#include "unicode/ures.h"
#include "unicode/tzfmt.h"
#include "unicode/numfmt.h"
#include "gregoimp.h"
#include "uresimp.h" // struct UResourceBundle
#include "olsontz.h"
#include "mutex.h"
#include "unicode/udata.h"
#include "ucln_in.h"
#include "cstring.h"
#include "cmemory.h"
#include "unicode/strenum.h"
#include "uassert.h"
#include "zonemeta.h"

#define kZONEINFO
#define kREGIONS
#define kZONES
#define kRULES
#define kNAMES
#define kTZVERSION
#define kLINKS
#define kMAX_CUSTOM_HOUR
#define kMAX_CUSTOM_MIN
#define kMAX_CUSTOM_SEC
#define MINUS
#define PLUS
#define ZERO_DIGIT
#define COLON

// Static data and constants

static const char16_t      WORLD[] =; /* "001" */

static const char16_t      GMT_ID[] =; /* "GMT" */
static const char16_t      UNKNOWN_ZONE_ID[] =; /* "Etc/Unknown" */
static const int32_t       GMT_ID_LENGTH =;
static const int32_t       UNKNOWN_ZONE_ID_LENGTH =;

static icu::TimeZone* DEFAULT_ZONE =;
static icu::UInitOnce gDefaultZoneInitOnce {};

alignas(icu::SimpleTimeZone)
static char gRawGMT[sizeof(icu::SimpleTimeZone)];

alignas(icu::SimpleTimeZone)
static char gRawUNKNOWN[sizeof(icu::SimpleTimeZone)];

static icu::UInitOnce gStaticZonesInitOnce {};
static UBool gStaticZonesInitialized =; // Whether the static zones are initialized and ready to use.

static char TZDATA_VERSION[16];
static icu::UInitOnce gTZDataVersionInitOnce {};

static int32_t* MAP_SYSTEM_ZONES =;
static int32_t* MAP_CANONICAL_SYSTEM_ZONES =;
static int32_t* MAP_CANONICAL_SYSTEM_LOCATION_ZONES =;

static int32_t LEN_SYSTEM_ZONES =;
static int32_t LEN_CANONICAL_SYSTEM_ZONES =;
static int32_t LEN_CANONICAL_SYSTEM_LOCATION_ZONES =;

static icu::UInitOnce gSystemZonesInitOnce {};
static icu::UInitOnce gCanonicalZonesInitOnce {};
static icu::UInitOnce gCanonicalLocationZonesInitOnce {};

U_CDECL_BEGIN
static UBool U_CALLCONV timeZone_cleanup()
{}
U_CDECL_END

U_NAMESPACE_BEGIN

#endif /* #if !UCONFIG_NO_FORMATTING */

//eof