mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
171
intl/icu/source/tools/tzcode/Makefile.in
Normal file
171
intl/icu/source/tools/tzcode/Makefile.in
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
# Some Portions Copyright (c) 2006-2012 IBM and others. All Rights Reserved.
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
subdir = tools/tzcode
|
||||
|
||||
include $(top_builddir)/icudefs.mk
|
||||
|
||||
ifeq ($(TZDATA),)
|
||||
TZDATA = $(firstword $(wildcard ./tzdata*.tar.gz) $(wildcard $(srcdir)/tzdata*.tar.gz))
|
||||
endif
|
||||
ifeq ($(TZCODE),)
|
||||
TZCODE = $(firstword $(wildcard ./tzcode*.tar.gz) $(wildcard $(srcdir)/tzcode*.tar.gz))
|
||||
endif
|
||||
|
||||
TZORIG=./tzorig
|
||||
TZORIG_TZDIR=./tzorig/tzdir
|
||||
TZORIG_ABS := $(shell pwd)/tzorig
|
||||
TZORIG_TZDIR_ABS := $(TZORIG_ABS)/tzdir
|
||||
TZORIG_OPTS := CFLAGS="-D_POSIX_C_SOURCE $(TZORIG_EXTRA_CFLAGS)" TZDIR=$(TZORIG_TZDIR_ABS)
|
||||
|
||||
|
||||
## Options for building zdumps
|
||||
ZDUMPOUT=$(shell pwd)/zdumpout
|
||||
ICUZDUMPOUT=$(shell pwd)/icuzdumpout
|
||||
|
||||
ZDUMP_OPTS= -v -a -d $(ZDUMPOUT) -c 1902,2038 -i
|
||||
ICUZDUMP_OPTS= -a -d $(ICUZDUMPOUT)
|
||||
|
||||
# Executables & objects
|
||||
OBJECTS= zic.o localtime.o asctime.o scheck.o ialloc.o
|
||||
ZICTARG=$(BINDIR)/zic$(EXEEXT)
|
||||
ZICEXEC=$(TOOLBINDIR)/zic$(TOOLEXEEXT)
|
||||
TZ2ICUTARG=$(BINDIR)/tz2icu$(EXEEXT)
|
||||
TZ2ICUEXEC=$(TOOLBINDIR)/tz2icu$(TOOLEXEEXT)
|
||||
ICUZDUMPTARG=$(BINDIR)/icuzdump$(EXEEXT)
|
||||
ICUZDUMPEXEC=$(TOOLBINDIR)/icuzdump$(TOOLEXEEXT)
|
||||
|
||||
ifeq ($(TZDATA),)
|
||||
all:
|
||||
@echo ERROR "tzdata*.tar.gz" can\'t be found.
|
||||
@false
|
||||
else
|
||||
all: icu_data
|
||||
endif
|
||||
|
||||
TZCODE_TARGETS= tzorig check-dump
|
||||
|
||||
ifeq ($(TZCODE),)
|
||||
# we're broken.
|
||||
$(TZCODE_TARGETS):
|
||||
@echo ERROR "tzcode*.tar.gz" can\'t be found.
|
||||
@false
|
||||
|
||||
else
|
||||
ifeq ($(TZDATA),)
|
||||
# we're broken.
|
||||
$(TZCODE_TARGETS):
|
||||
@echo ERROR "tzdata*.tar.gz" can\'t be found.
|
||||
@false
|
||||
else
|
||||
tzorig: $(TZCODE) $(TZDATA)
|
||||
-$(RMV) ./tzorig/
|
||||
mkdir $@
|
||||
mkdir $(TZORIG_TZDIR)
|
||||
gunzip -d < $(TZDATA) | ( cd $@ ; tar xf - )
|
||||
gunzip -d < $(TZCODE) | ( cd $@ ; tar xf - )
|
||||
-mv $(TZORIG)/zdump.c $(TZORIG)/zdump.c.orig
|
||||
cp $(srcdir)/zdump.c $(TZORIG)/zdump.c
|
||||
-mv $(TZORIG)/factory $(TZORIG)/factory.orig
|
||||
cat $(TZORIG)/factory.orig $(srcdir)/icuzones > $(TZORIG)/factory
|
||||
$(MAKE) -C $@ $(TZORIG_OPTS) zdump zones
|
||||
|
||||
$(ZDUMPOUT): tzorig
|
||||
( cd $(TZORIG) ; ./zdump$(EXEEXT) $(ZDUMP_OPTS) )
|
||||
|
||||
|
||||
dump-out: $(ZDUMPOUT) $(ICUZDUMPOUT)
|
||||
|
||||
check-dump: dump-out
|
||||
diff -r zdumpout icuzdumpout
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
$(ICUZDUMPOUT): $(ICUZDUMPEXEC)
|
||||
-$(RMV) $(ICUZDUMPOUT)
|
||||
-mkdir $(ICUZDUMPOUT)
|
||||
$(INVOKE) $(ICUZDUMPEXEC) $(ICUZDUMP_OPTS)
|
||||
|
||||
|
||||
#
|
||||
# old 'tz' rules start here
|
||||
#
|
||||
|
||||
|
||||
PRIMARY_YDATA= africa antarctica asia australasia \
|
||||
europe northamerica southamerica
|
||||
YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
|
||||
NDATA= systemv
|
||||
SDATA= solar87 solar88 solar89
|
||||
#TDATA= $(YDATA) $(NDATA) $(SDATA)
|
||||
TDATA= $(YDATA) $(NDATA)
|
||||
YEARISTYPE= ./yearistype
|
||||
|
||||
TZDIR=zoneinfo
|
||||
|
||||
CFLAGS+=-D_POSIX_C_SOURCE
|
||||
CPPFLAGS+= -DTZDIR=\"$(TZDIR)\"
|
||||
|
||||
# more data
|
||||
XDATA=zone.tab yearistype.sh leapseconds iso3166.tab
|
||||
ICUDATA=ZoneMetaData.java icu_zone.txt tz2icu zoneinfo64.txt zoneinfo.txt
|
||||
|
||||
$(ZICTARG): $(OBJECTS) $(TDATA) yearistype $(srcdir)/tz2icu.h
|
||||
$(CC) $(CFLAGS) $(TZORIG_EXTRA_CFLAGS) $(LFLAGS) -I$(srcdir) $(OBJECTS) $(LDLIBS) -o $@
|
||||
|
||||
$(TZ2ICUTARG): $(srcdir)/tz2icu.cpp $(srcdir)/tz2icu.h
|
||||
$(CXX) -W -Wall -I$(srcdir) -I$(top_srcdir)/common -pedantic $(srcdir)/tz2icu.cpp -o $@
|
||||
|
||||
$(ICUZDUMPTARG): $(srcdir)/icuzdump.cpp
|
||||
$(LINK.cc) -I$(srcdir) -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/io -pedantic $(srcdir)/icuzdump.cpp $(LIBICUUC) $(LIBICUDT) $(LIBICUI18N) $(LIBICUIO) $(LIBICUTOOLUTIL) -o $@
|
||||
|
||||
|
||||
$(TDATA): tdatamarker
|
||||
|
||||
tdatamarker: $(TZDATA)
|
||||
gunzip -d < $(TZDATA) | tar xf - --exclude=Makefile
|
||||
touch $@
|
||||
|
||||
yearistype: yearistype.sh
|
||||
cp yearistype.sh yearistype
|
||||
chmod +x yearistype
|
||||
|
||||
posix_only: $(ZICEXEC) $(TDATA) $(srcdir)/icuzones
|
||||
$(ZICEXEC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA) $(srcdir)/icuzones
|
||||
|
||||
|
||||
icu_data: $(TZ2ICUEXEC) posix_only
|
||||
$(TZ2ICUEXEC) $(TZDIR) zone.tab `echo $(TZDATA) | sed -e "s/.*\/tzdata//;s/\.tar\.gz$$//"`
|
||||
$(TZ2ICUEXEC) $(TZDIR) zone.tab `echo $(TZDATA) | sed -e "s/.*\/tzdata//;s/\.tar\.gz$$//"` --old
|
||||
|
||||
clean:
|
||||
-rm -f core *.o *.out zdump${EXEEXT} $(ZICTARG) yearistype date $(TZ2ICUTARG)
|
||||
@echo ICU specific cleanup:
|
||||
-rm -f $(ICUDATA)
|
||||
-rm -rf $(TZDIR)
|
||||
-$(RMV) $(ICUZDUMPTARG) tzorig ./zdumpout/ ./icuzdumpout/
|
||||
ifneq ($(TZDATA),)
|
||||
-rm -rf `gunzip -d < $(TZDATA) | tar tf - --exclude=Makefile | grep -o '[^ ]*$$' | tr '\n' ' '`
|
||||
-rm tdatamarker
|
||||
endif
|
||||
|
||||
checkclean:
|
||||
|
||||
dataclean: clean
|
||||
-rm -f $(TDATA) $(XDATA)
|
||||
|
||||
distclean: dataclean clean
|
||||
-rm -f Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
132
intl/icu/source/tools/tzcode/asctime.c
Normal file
132
intl/icu/source/tools/tzcode/asctime.c
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 1996-06-05 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Avoid the temptation to punt entirely to strftime;
|
||||
** the output of strftime is supposed to be locale specific
|
||||
** whereas the output of asctime is supposed to be constant.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "private.h"
|
||||
#include "tzfile.h"
|
||||
|
||||
/*
|
||||
** Some systems only handle "%.2d"; others only handle "%02d";
|
||||
** "%02.2d" makes (most) everybody happy.
|
||||
** At least some versions of gcc warn about the %02.2d;
|
||||
** we conditionalize below to avoid the warning.
|
||||
*/
|
||||
/*
|
||||
** All years associated with 32-bit time_t values are exactly four digits long;
|
||||
** some years associated with 64-bit time_t values are not.
|
||||
** Vintage programs are coded for years that are always four digits long
|
||||
** and may assume that the newline always lands in the same place.
|
||||
** For years that are less than four digits, we pad the output with
|
||||
** leading zeroes to get the newline in the traditional place.
|
||||
** The -4 ensures that we get four characters of output even if
|
||||
** we call a strftime variant that produces fewer characters for some years.
|
||||
** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year,
|
||||
** but many implementations pad anyway; most likely the standards are buggy.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n"
|
||||
#else /* !defined __GNUC__ */
|
||||
#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n"
|
||||
#endif /* !defined __GNUC__ */
|
||||
/*
|
||||
** For years that are more than four digits we put extra spaces before the year
|
||||
** so that code trying to overwrite the newline won't end up overwriting
|
||||
** a digit within a year and truncating the year (operating on the assumption
|
||||
** that no output is better than wrong output).
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n"
|
||||
#else /* !defined __GNUC__ */
|
||||
#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n"
|
||||
#endif /* !defined __GNUC__ */
|
||||
|
||||
#define STD_ASCTIME_BUF_SIZE 26
|
||||
/*
|
||||
** Big enough for something such as
|
||||
** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
|
||||
** (two three-character abbreviations, five strings denoting integers,
|
||||
** seven explicit spaces, two explicit colons, a newline,
|
||||
** and a trailing ASCII nul).
|
||||
** The values above are for systems where an int is 32 bits and are provided
|
||||
** as an example; the define below calculates the maximum for the system at
|
||||
** hand.
|
||||
*/
|
||||
#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1)
|
||||
|
||||
static char buf_asctime[MAX_ASCTIME_BUF_SIZE];
|
||||
|
||||
/*
|
||||
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
|
||||
*/
|
||||
|
||||
char *
|
||||
asctime_r(register const struct tm *timeptr, char *buf)
|
||||
{
|
||||
static const char wday_name[][3] = {
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
||||
};
|
||||
static const char mon_name[][3] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
register const char * wn;
|
||||
register const char * mn;
|
||||
char year[INT_STRLEN_MAXIMUM(int) + 2];
|
||||
char result[MAX_ASCTIME_BUF_SIZE];
|
||||
|
||||
if (timeptr == NULL) {
|
||||
errno = EINVAL;
|
||||
return strcpy(buf, "??? ??? ?? ??:??:?? ????\n");
|
||||
}
|
||||
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
|
||||
wn = "???";
|
||||
else wn = wday_name[timeptr->tm_wday];
|
||||
if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR)
|
||||
mn = "???";
|
||||
else mn = mon_name[timeptr->tm_mon];
|
||||
/*
|
||||
** Use strftime's %Y to generate the year, to avoid overflow problems
|
||||
** when computing timeptr->tm_year + TM_YEAR_BASE.
|
||||
** Assume that strftime is unaffected by other out-of-range members
|
||||
** (e.g., timeptr->tm_mday) when processing "%Y".
|
||||
*/
|
||||
(void) strftime(year, sizeof year, "%Y", timeptr);
|
||||
/*
|
||||
** We avoid using snprintf since it's not available on all systems.
|
||||
*/
|
||||
(void) sprintf(result,
|
||||
((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B),
|
||||
wn, mn,
|
||||
timeptr->tm_mday, timeptr->tm_hour,
|
||||
timeptr->tm_min, timeptr->tm_sec,
|
||||
year);
|
||||
if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime)
|
||||
return strcpy(buf, result);
|
||||
else {
|
||||
#ifdef EOVERFLOW
|
||||
errno = EOVERFLOW;
|
||||
#else /* !defined EOVERFLOW */
|
||||
errno = EINVAL;
|
||||
#endif /* !defined EOVERFLOW */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
|
||||
*/
|
||||
|
||||
char *
|
||||
asctime(register const struct tm *timeptr)
|
||||
{
|
||||
return asctime_r(timeptr, buf_asctime);
|
||||
}
|
||||
32
intl/icu/source/tools/tzcode/ialloc.c
Normal file
32
intl/icu/source/tools/tzcode/ialloc.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 2006-07-17 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "private.h"
|
||||
|
||||
char *
|
||||
icatalloc(char *const old, const char *const new)
|
||||
{
|
||||
register char * result;
|
||||
register int oldsize, newsize;
|
||||
|
||||
newsize = (new == NULL) ? 0 : strlen(new);
|
||||
if (old == NULL)
|
||||
oldsize = 0;
|
||||
else if (newsize == 0)
|
||||
return old;
|
||||
else oldsize = strlen(old);
|
||||
if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
|
||||
if (new != NULL)
|
||||
(void) strcpy(result + oldsize, new);
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
icpyalloc(const char *const string)
|
||||
{
|
||||
return icatalloc(NULL, string);
|
||||
}
|
||||
15
intl/icu/source/tools/tzcode/icuregions
Normal file
15
intl/icu/source/tools/tzcode/icuregions
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
######################################################################
|
||||
# Copyright (C) 2013-2014, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
######################################################################
|
||||
# This is an ICU-specific file including zone/region mapping.
|
||||
#
|
||||
# Each line below indicates zone and its region in the syntax below -
|
||||
# <zone_id> <region_code>
|
||||
#
|
||||
Africa/Asmera ER
|
||||
America/Montreal CA
|
||||
Europe/Simferopol UA
|
||||
|
||||
423
intl/icu/source/tools/tzcode/icuzdump.cpp
Normal file
423
intl/icu/source/tools/tzcode/icuzdump.cpp
Normal file
|
|
@ -0,0 +1,423 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2007-2016, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
* file name: icuzdump.cpp
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2007-04-02
|
||||
* created by: Yoshito Umaoka
|
||||
*
|
||||
* This tool write out timezone transitions for ICU timezone. This tool
|
||||
* is used as a part of tzdata update process to check if ICU timezone
|
||||
* code works as well as the corresponding Olson stock localtime/zdump.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/timezone.h"
|
||||
#include "unicode/simpletz.h"
|
||||
#include "unicode/smpdtfmt.h"
|
||||
#include "unicode/decimfmt.h"
|
||||
#include "unicode/gregocal.h"
|
||||
#include "unicode/ustream.h"
|
||||
#include "unicode/putil.h"
|
||||
|
||||
#include "cmemory.h"
|
||||
#include "uoptions.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DumpFormatter {
|
||||
public:
|
||||
DumpFormatter() {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
stz = new SimpleTimeZone(0, "");
|
||||
sdf = new SimpleDateFormat((UnicodeString)"yyyy-MM-dd EEE HH:mm:ss", Locale::getEnglish(), status);
|
||||
DecimalFormatSymbols *symbols = new DecimalFormatSymbols(Locale::getEnglish(), status);
|
||||
decf = new DecimalFormat("00", symbols, status);
|
||||
}
|
||||
~DumpFormatter() {
|
||||
}
|
||||
|
||||
UnicodeString& format(UDate time, int32_t offset, UBool isDst, UnicodeString& appendTo) {
|
||||
stz->setRawOffset(offset);
|
||||
sdf->setTimeZone(*stz);
|
||||
UnicodeString str = sdf->format(time, appendTo);
|
||||
if (offset < 0) {
|
||||
appendTo += "-";
|
||||
offset = -offset;
|
||||
} else {
|
||||
appendTo += "+";
|
||||
}
|
||||
|
||||
int32_t hour, min, sec;
|
||||
|
||||
offset /= 1000;
|
||||
sec = offset % 60;
|
||||
offset = (offset - sec) / 60;
|
||||
min = offset % 60;
|
||||
hour = offset / 60;
|
||||
|
||||
decf->format(hour, appendTo);
|
||||
decf->format(min, appendTo);
|
||||
decf->format(sec, appendTo);
|
||||
appendTo += "[DST=";
|
||||
if (isDst) {
|
||||
appendTo += "1";
|
||||
} else {
|
||||
appendTo += "0";
|
||||
}
|
||||
appendTo += "]";
|
||||
return appendTo;
|
||||
}
|
||||
private:
|
||||
SimpleTimeZone* stz;
|
||||
SimpleDateFormat* sdf;
|
||||
DecimalFormat* decf;
|
||||
};
|
||||
|
||||
class ICUZDump {
|
||||
public:
|
||||
ICUZDump() {
|
||||
formatter = new DumpFormatter();
|
||||
loyear = 1902;
|
||||
hiyear = 2050;
|
||||
tick = 1000;
|
||||
linesep = NULL;
|
||||
}
|
||||
|
||||
~ICUZDump() {
|
||||
}
|
||||
|
||||
void setLowYear(int32_t lo) {
|
||||
loyear = lo;
|
||||
}
|
||||
|
||||
void setHighYear(int32_t hi) {
|
||||
hiyear = hi;
|
||||
}
|
||||
|
||||
void setTick(int32_t t) {
|
||||
tick = t;
|
||||
}
|
||||
|
||||
void setTimeZone(TimeZone* tz) {
|
||||
timezone = tz;
|
||||
}
|
||||
|
||||
void setDumpFormatter(DumpFormatter* fmt) {
|
||||
formatter = fmt;
|
||||
}
|
||||
|
||||
void setLineSeparator(const char* sep) {
|
||||
linesep = sep;
|
||||
}
|
||||
|
||||
void dump(ostream& out) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UDate SEARCH_INCREMENT = 12 * 60 * 60 * 1000; // half day
|
||||
UDate t, cutlo, cuthi;
|
||||
int32_t rawOffset, dstOffset;
|
||||
UnicodeString str;
|
||||
|
||||
getCutOverTimes(cutlo, cuthi);
|
||||
t = cutlo;
|
||||
timezone->getOffset(t, FALSE, rawOffset, dstOffset, status);
|
||||
while (t < cuthi) {
|
||||
int32_t newRawOffset, newDstOffset;
|
||||
UDate newt = t + SEARCH_INCREMENT;
|
||||
|
||||
timezone->getOffset(newt, FALSE, newRawOffset, newDstOffset, status);
|
||||
|
||||
UBool bSameOffset = (rawOffset + dstOffset) == (newRawOffset + newDstOffset);
|
||||
UBool bSameDst = ((dstOffset != 0) && (newDstOffset != 0)) || ((dstOffset == 0) && (newDstOffset == 0));
|
||||
|
||||
if (!bSameOffset || !bSameDst) {
|
||||
// find the boundary
|
||||
UDate lot = t;
|
||||
UDate hit = newt;
|
||||
while (true) {
|
||||
int32_t diff = (int32_t)(hit - lot);
|
||||
if (diff <= tick) {
|
||||
break;
|
||||
}
|
||||
UDate medt = lot + ((diff / 2) / tick) * tick;
|
||||
int32_t medRawOffset, medDstOffset;
|
||||
timezone->getOffset(medt, FALSE, medRawOffset, medDstOffset, status);
|
||||
|
||||
bSameOffset = (rawOffset + dstOffset) == (medRawOffset + medDstOffset);
|
||||
bSameDst = ((dstOffset != 0) && (medDstOffset != 0)) || ((dstOffset == 0) && (medDstOffset == 0));
|
||||
|
||||
if (!bSameOffset || !bSameDst) {
|
||||
hit = medt;
|
||||
} else {
|
||||
lot = medt;
|
||||
}
|
||||
}
|
||||
// write out the boundary
|
||||
str.remove();
|
||||
formatter->format(lot, rawOffset + dstOffset, (dstOffset == 0 ? FALSE : TRUE), str);
|
||||
out << str << " > ";
|
||||
str.remove();
|
||||
formatter->format(hit, newRawOffset + newDstOffset, (newDstOffset == 0 ? FALSE : TRUE), str);
|
||||
out << str;
|
||||
if (linesep != NULL) {
|
||||
out << linesep;
|
||||
} else {
|
||||
out << endl;
|
||||
}
|
||||
|
||||
rawOffset = newRawOffset;
|
||||
dstOffset = newDstOffset;
|
||||
}
|
||||
t = newt;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void getCutOverTimes(UDate& lo, UDate& hi) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
GregorianCalendar* gcal = new GregorianCalendar(timezone, Locale::getEnglish(), status);
|
||||
gcal->clear();
|
||||
gcal->set(loyear, 0, 1, 0, 0, 0);
|
||||
lo = gcal->getTime(status);
|
||||
gcal->set(hiyear, 0, 1, 0, 0, 0);
|
||||
hi = gcal->getTime(status);
|
||||
}
|
||||
|
||||
TimeZone* timezone;
|
||||
int32_t loyear;
|
||||
int32_t hiyear;
|
||||
int32_t tick;
|
||||
|
||||
DumpFormatter* formatter;
|
||||
const char* linesep;
|
||||
};
|
||||
|
||||
class ZoneIterator {
|
||||
public:
|
||||
ZoneIterator(UBool bAll = FALSE) {
|
||||
if (bAll) {
|
||||
zenum = TimeZone::createEnumeration();
|
||||
}
|
||||
else {
|
||||
zenum = NULL;
|
||||
zids = NULL;
|
||||
idx = 0;
|
||||
numids = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ZoneIterator(const char** ids, int32_t num) {
|
||||
zenum = NULL;
|
||||
zids = ids;
|
||||
idx = 0;
|
||||
numids = num;
|
||||
}
|
||||
|
||||
~ZoneIterator() {
|
||||
if (zenum != NULL) {
|
||||
delete zenum;
|
||||
}
|
||||
}
|
||||
|
||||
TimeZone* next() {
|
||||
TimeZone* tz = NULL;
|
||||
if (zenum != NULL) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
const UnicodeString* zid = zenum->snext(status);
|
||||
if (zid != NULL) {
|
||||
tz = TimeZone::createTimeZone(*zid);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (idx < numids) {
|
||||
if (zids != NULL) {
|
||||
tz = TimeZone::createTimeZone((const UnicodeString&)zids[idx]);
|
||||
}
|
||||
else {
|
||||
tz = TimeZone::createDefault();
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
return tz;
|
||||
}
|
||||
|
||||
private:
|
||||
const char** zids;
|
||||
StringEnumeration* zenum;
|
||||
int32_t idx;
|
||||
int32_t numids;
|
||||
};
|
||||
|
||||
enum {
|
||||
kOptHelpH = 0,
|
||||
kOptHelpQuestionMark,
|
||||
kOptAllZones,
|
||||
kOptCutover,
|
||||
kOptDestDir,
|
||||
kOptLineSep
|
||||
};
|
||||
|
||||
static UOption options[]={
|
||||
UOPTION_HELP_H,
|
||||
UOPTION_HELP_QUESTION_MARK,
|
||||
UOPTION_DEF("allzones", 'a', UOPT_NO_ARG),
|
||||
UOPTION_DEF("cutover", 'c', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF("destdir", 'd', UOPT_REQUIRES_ARG),
|
||||
UOPTION_DEF("linesep", 'l', UOPT_REQUIRES_ARG)
|
||||
};
|
||||
|
||||
extern int
|
||||
main(int argc, char *argv[]) {
|
||||
int32_t low = 1902;
|
||||
int32_t high = 2038;
|
||||
UBool bAll = FALSE;
|
||||
const char *dir = NULL;
|
||||
const char *linesep = NULL;
|
||||
|
||||
U_MAIN_INIT_ARGS(argc, argv);
|
||||
argc = u_parseArgs(argc, argv, UPRV_LENGTHOF(options), options);
|
||||
|
||||
if (argc < 0) {
|
||||
cerr << "Illegal command line argument(s)" << endl << endl;
|
||||
}
|
||||
|
||||
if (argc < 0 || options[kOptHelpH].doesOccur || options[kOptHelpQuestionMark].doesOccur) {
|
||||
cerr
|
||||
<< "Usage: icuzdump [-options] [zoneid1 zoneid2 ...]" << endl
|
||||
<< endl
|
||||
<< "\tDump all offset transitions for the specified zones." << endl
|
||||
<< endl
|
||||
<< "Options:" << endl
|
||||
<< "\t-a : Dump all available zones." << endl
|
||||
<< "\t-d <dir> : When specified, write transitions in a file under" << endl
|
||||
<< "\t the directory for each zone." << endl
|
||||
<< "\t-l <sep> : New line code type used in file outputs. CR or LF (default)"
|
||||
<< "\t or CRLF." << endl
|
||||
<< "\t-c [<low_year>,]<high_year>" << endl
|
||||
<< "\t : When specified, dump transitions starting <low_year>" << endl
|
||||
<< "\t (inclusive) up to <high_year> (exclusive). The default" << endl
|
||||
<< "\t values are 1902(low) and 2038(high)." << endl;
|
||||
return argc < 0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
|
||||
}
|
||||
|
||||
bAll = options[kOptAllZones].doesOccur;
|
||||
|
||||
if (options[kOptDestDir].doesOccur) {
|
||||
dir = options[kOptDestDir].value;
|
||||
}
|
||||
|
||||
if (options[kOptLineSep].doesOccur) {
|
||||
if (strcmp(options[kOptLineSep].value, "CR") == 0) {
|
||||
linesep = "\r";
|
||||
} else if (strcmp(options[kOptLineSep].value, "CRLF") == 0) {
|
||||
linesep = "\r\n";
|
||||
} else if (strcmp(options[kOptLineSep].value, "LF") == 0) {
|
||||
linesep = "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (options[kOptCutover].doesOccur) {
|
||||
char* comma = (char*)strchr(options[kOptCutover].value, ',');
|
||||
if (comma == NULL) {
|
||||
high = atoi(options[kOptCutover].value);
|
||||
} else {
|
||||
*comma = 0;
|
||||
low = atoi(options[kOptCutover].value);
|
||||
high = atoi(comma + 1);
|
||||
}
|
||||
}
|
||||
|
||||
ICUZDump dumper;
|
||||
dumper.setLowYear(low);
|
||||
dumper.setHighYear(high);
|
||||
if (dir != NULL && linesep != NULL) {
|
||||
// use the specified line separator only for file output
|
||||
dumper.setLineSeparator((const char*)linesep);
|
||||
}
|
||||
|
||||
ZoneIterator* zit;
|
||||
if (bAll) {
|
||||
zit = new ZoneIterator(TRUE);
|
||||
} else {
|
||||
if (argc <= 1) {
|
||||
zit = new ZoneIterator();
|
||||
} else {
|
||||
zit = new ZoneIterator((const char**)&argv[1], argc - 1);
|
||||
}
|
||||
}
|
||||
|
||||
UnicodeString id;
|
||||
if (dir != NULL) {
|
||||
// file output
|
||||
ostringstream path;
|
||||
ios::openmode mode = ios::out;
|
||||
if (linesep != NULL) {
|
||||
mode |= ios::binary;
|
||||
}
|
||||
for (;;) {
|
||||
TimeZone* tz = zit->next();
|
||||
if (tz == NULL) {
|
||||
break;
|
||||
}
|
||||
dumper.setTimeZone(tz);
|
||||
tz->getID(id);
|
||||
|
||||
// target file path
|
||||
path.str("");
|
||||
path << dir << U_FILE_SEP_CHAR;
|
||||
id = id.findAndReplace("/", "-");
|
||||
path << id;
|
||||
|
||||
ofstream* fout = new ofstream(path.str().c_str(), mode);
|
||||
if (fout->fail()) {
|
||||
cerr << "Cannot open file " << path.str() << endl;
|
||||
delete fout;
|
||||
delete tz;
|
||||
break;
|
||||
}
|
||||
|
||||
dumper.dump(*fout);
|
||||
fout->close();
|
||||
delete fout;
|
||||
delete tz;
|
||||
}
|
||||
|
||||
} else {
|
||||
// stdout
|
||||
UBool bFirst = TRUE;
|
||||
for (;;) {
|
||||
TimeZone* tz = zit->next();
|
||||
if (tz == NULL) {
|
||||
break;
|
||||
}
|
||||
dumper.setTimeZone(tz);
|
||||
tz->getID(id);
|
||||
if (bFirst) {
|
||||
bFirst = FALSE;
|
||||
} else {
|
||||
cout << endl;
|
||||
}
|
||||
cout << "ZONE: " << id << endl;
|
||||
dumper.dump(cout);
|
||||
delete tz;
|
||||
}
|
||||
}
|
||||
delete zit;
|
||||
}
|
||||
111
intl/icu/source/tools/tzcode/icuzdump.vcxproj
Normal file
111
intl/icu/source/tools/tzcode/icuzdump.vcxproj
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{655F4481-B461-4DF0-AF10-0D01114A26C1}</ProjectGuid>
|
||||
<RootNamespace>icuzdump</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<CustomBuildStep>
|
||||
<Command>copy "$(TargetPath)" ..\..\..\bin
|
||||
</Command>
|
||||
<Outputs>..\..\..\bin\$(TargetFileName);%(Outputs)</Outputs>
|
||||
</CustomBuildStep>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\..\..\include;..\toolutil;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<DisableLanguageExtensions>true</DisableLanguageExtensions>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>.\x86\Debug/icuzdump.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\x86\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>icuucd.lib;icuind.lib;icutud.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>.\x86\Debug/icuzdump.exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>.\x86\Debug/icuzdump.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>NotSet</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="icuzdump.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
intl/icu/source/tools/tzcode/icuzdump.vcxproj.filters
Normal file
22
intl/icu/source/tools/tzcode/icuzdump.vcxproj.filters
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="icuzdump.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
73
intl/icu/source/tools/tzcode/icuzones
Normal file
73
intl/icu/source/tools/tzcode/icuzones
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
# License & terms of use: http://www.unicode.org/copyright.html
|
||||
######################################################################
|
||||
# Copyright (C) 2007-2014, International Business Machines
|
||||
# Corporation and others. All Rights Reserved.
|
||||
######################################################################
|
||||
# This is an ICU-specific file with the same format as regular
|
||||
# tzdata time zone files, for consistent parsing by the tools that
|
||||
# turn "Olson" tzdata into ICU's zoneinfo.txt.
|
||||
# The purpose of this file is to give ICU a superset of the time zones
|
||||
# that are in CLDR and also include legacy ICU time zones originally
|
||||
# in tz.alias for rataining backward compatibility.
|
||||
|
||||
# Add Etc/Unknown, defined by CLDR. Give it Etc/GMT behavior.
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT
|
||||
Zone Etc/Unknown 0 - Unknown
|
||||
|
||||
# SystemV time zones.
|
||||
# The Olson systemv file has these commented out.
|
||||
|
||||
# Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
|
||||
Zone SystemV/AST4ADT -4:00 SystemV A%sT
|
||||
Zone SystemV/EST5EDT -5:00 SystemV E%sT
|
||||
Zone SystemV/CST6CDT -6:00 SystemV C%sT
|
||||
Zone SystemV/MST7MDT -7:00 SystemV M%sT
|
||||
Zone SystemV/PST8PDT -8:00 SystemV P%sT
|
||||
Zone SystemV/YST9YDT -9:00 SystemV Y%sT
|
||||
Zone SystemV/AST4 -4:00 - AST
|
||||
Zone SystemV/EST5 -5:00 - EST
|
||||
Zone SystemV/CST6 -6:00 - CST
|
||||
Zone SystemV/MST7 -7:00 - MST
|
||||
Zone SystemV/PST8 -8:00 - PST
|
||||
Zone SystemV/YST9 -9:00 - YST
|
||||
Zone SystemV/HST10 -10:00 - HST
|
||||
|
||||
|
||||
# The list below is for supporting legacy ICU zone aliases.
|
||||
# These definitions were originally defined in tz.alias.
|
||||
|
||||
#### Aliases that conflict with Olson compatibility Zone definition
|
||||
|
||||
Link Australia/Darwin ACT
|
||||
Link Australia/Sydney AET
|
||||
Link America/Argentina/Buenos_Aires AGT
|
||||
Link Africa/Cairo ART
|
||||
Link America/Anchorage AST
|
||||
Link America/Sao_Paulo BET
|
||||
Link Asia/Dhaka BST
|
||||
Link Africa/Maputo CAT
|
||||
Link America/St_Johns CNT
|
||||
Link America/Chicago CST
|
||||
Link Asia/Shanghai CTT
|
||||
Link Africa/Addis_Ababa EAT
|
||||
Link Europe/Paris ECT
|
||||
#Link Europe/Istanbul EET # EET is a standard UNIX zone
|
||||
####Link EST America/New_York EST # Defined as -05:00
|
||||
####Link Pacific/Honolulu HST # Defined as -10:00
|
||||
Link America/Indiana/Indianapolis IET
|
||||
Link Asia/Kolkata IST
|
||||
Link Asia/Tokyo JST
|
||||
#Link Asia/Tehran MET # MET is a standard UNIX zone
|
||||
Link Pacific/Apia MIT
|
||||
####Link America/Denver MST # Defined as -07:00
|
||||
Link Asia/Yerevan NET
|
||||
Link Pacific/Auckland NST
|
||||
Link Asia/Karachi PLT
|
||||
Link America/Phoenix PNT
|
||||
Link America/Puerto_Rico PRT
|
||||
Link America/Los_Angeles PST
|
||||
Link Pacific/Guadalcanal SST
|
||||
#Link Etc/UTC UTC # Olson LINK
|
||||
Link Asia/Ho_Chi_Minh VST
|
||||
2056
intl/icu/source/tools/tzcode/localtime.c
Normal file
2056
intl/icu/source/tools/tzcode/localtime.c
Normal file
File diff suppressed because it is too large
Load diff
423
intl/icu/source/tools/tzcode/private.h
Normal file
423
intl/icu/source/tools/tzcode/private.h
Normal file
|
|
@ -0,0 +1,423 @@
|
|||
#ifndef PRIVATE_H
|
||||
|
||||
#define PRIVATE_H
|
||||
|
||||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 1996-06-05 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is for use ONLY with the time conversion code.
|
||||
** There is no guarantee that it will remain unchanged,
|
||||
** or that it will remain at all.
|
||||
** Do NOT copy it to any system include directory.
|
||||
** Thank you!
|
||||
*/
|
||||
|
||||
#define GRANDPARENTED "Local time zone must be set--see zic manual page"
|
||||
|
||||
/*
|
||||
** Defaults for preprocessor symbols.
|
||||
** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_ADJTIME
|
||||
#define HAVE_ADJTIME 1
|
||||
#endif /* !defined HAVE_ADJTIME */
|
||||
|
||||
#ifndef HAVE_GETTEXT
|
||||
#define HAVE_GETTEXT 0
|
||||
#endif /* !defined HAVE_GETTEXT */
|
||||
|
||||
#ifndef HAVE_INCOMPATIBLE_CTIME_R
|
||||
#define HAVE_INCOMPATIBLE_CTIME_R 0
|
||||
#endif /* !defined INCOMPATIBLE_CTIME_R */
|
||||
|
||||
#ifndef HAVE_LINK
|
||||
#define HAVE_LINK 1
|
||||
#endif /* !defined HAVE_LINK */
|
||||
|
||||
#ifndef HAVE_SETTIMEOFDAY
|
||||
#define HAVE_SETTIMEOFDAY 3
|
||||
#endif /* !defined HAVE_SETTIMEOFDAY */
|
||||
|
||||
#ifndef HAVE_SYMLINK
|
||||
#define HAVE_SYMLINK 1
|
||||
#endif /* !defined HAVE_SYMLINK */
|
||||
|
||||
#ifndef HAVE_SYS_STAT_H
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#endif /* !defined HAVE_SYS_STAT_H */
|
||||
|
||||
#ifndef HAVE_SYS_WAIT_H
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#endif /* !defined HAVE_SYS_WAIT_H */
|
||||
|
||||
#ifndef HAVE_UNISTD_H
|
||||
#define HAVE_UNISTD_H 1
|
||||
#endif /* !defined HAVE_UNISTD_H */
|
||||
|
||||
#ifndef HAVE_UTMPX_H
|
||||
#define HAVE_UTMPX_H 0
|
||||
#endif /* !defined HAVE_UTMPX_H */
|
||||
|
||||
#ifndef LOCALE_HOME
|
||||
#define LOCALE_HOME "/usr/lib/locale"
|
||||
#endif /* !defined LOCALE_HOME */
|
||||
|
||||
#if HAVE_INCOMPATIBLE_CTIME_R
|
||||
#define asctime_r _incompatible_asctime_r
|
||||
#define ctime_r _incompatible_ctime_r
|
||||
#endif /* HAVE_INCOMPATIBLE_CTIME_R */
|
||||
|
||||
/*
|
||||
** Nested includes
|
||||
*/
|
||||
|
||||
#include "sys/types.h" /* for time_t */
|
||||
#include "stdio.h"
|
||||
#include "errno.h"
|
||||
#include "string.h"
|
||||
#include "limits.h" /* for CHAR_BIT et al. */
|
||||
#include "time.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
#if HAVE_GETTEXT
|
||||
#include "libintl.h"
|
||||
#endif /* HAVE_GETTEXT */
|
||||
|
||||
#if HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
|
||||
#endif /* HAVE_SYS_WAIT_H */
|
||||
|
||||
#ifndef WIFEXITED
|
||||
#define WIFEXITED(status) (((status) & 0xff) == 0)
|
||||
#endif /* !defined WIFEXITED */
|
||||
#ifndef WEXITSTATUS
|
||||
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
|
||||
#endif /* !defined WEXITSTATUS */
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#ifndef F_OK
|
||||
#define F_OK 0
|
||||
#endif /* !defined F_OK */
|
||||
#ifndef R_OK
|
||||
#define R_OK 4
|
||||
#endif /* !defined R_OK */
|
||||
|
||||
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
|
||||
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
|
||||
|
||||
/*
|
||||
** Define HAVE_STDINT_H's default value here, rather than at the
|
||||
** start, since __GLIBC__'s value depends on previously-included
|
||||
** files.
|
||||
** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
|
||||
*/
|
||||
#ifndef HAVE_STDINT_H
|
||||
#define HAVE_STDINT_H \
|
||||
(199901 <= __STDC_VERSION__ || \
|
||||
2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
|
||||
#endif /* !defined HAVE_STDINT_H */
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include "stdint.h"
|
||||
#endif /* !HAVE_STDINT_H */
|
||||
|
||||
#ifndef HAVE_INTTYPES_H
|
||||
# define HAVE_INTTYPES_H HAVE_STDINT_H
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifndef INT_FAST64_MAX
|
||||
/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
|
||||
#if defined LLONG_MAX || defined __LONG_LONG_MAX__
|
||||
typedef long long int_fast64_t;
|
||||
# ifdef LLONG_MAX
|
||||
# define INT_FAST64_MIN LLONG_MIN
|
||||
# define INT_FAST64_MAX LLONG_MAX
|
||||
# else
|
||||
# define INT_FAST64_MIN __LONG_LONG_MIN__
|
||||
# define INT_FAST64_MAX __LONG_LONG_MAX__
|
||||
# endif
|
||||
# define SCNdFAST64 "lld"
|
||||
#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
|
||||
#if (LONG_MAX >> 31) < 0xffffffff
|
||||
Please use a compiler that supports a 64-bit integer type (or wider);
|
||||
you may need to compile with "-DHAVE_STDINT_H".
|
||||
#endif /* (LONG_MAX >> 31) < 0xffffffff */
|
||||
typedef long int_fast64_t;
|
||||
# define INT_FAST64_MIN LONG_MIN
|
||||
# define INT_FAST64_MAX LONG_MAX
|
||||
# define SCNdFAST64 "ld"
|
||||
#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
|
||||
#endif /* !defined INT_FAST64_MAX */
|
||||
|
||||
#ifndef INT_FAST32_MAX
|
||||
# if INT_MAX >> 31 == 0
|
||||
typedef long int_fast32_t;
|
||||
# else
|
||||
typedef int int_fast32_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INTMAX_MAX
|
||||
# if defined LLONG_MAX || defined __LONG_LONG_MAX__
|
||||
typedef long long intmax_t;
|
||||
# define strtoimax strtoll
|
||||
# define PRIdMAX "lld"
|
||||
# ifdef LLONG_MAX
|
||||
# define INTMAX_MAX LLONG_MAX
|
||||
# define INTMAX_MIN LLONG_MIN
|
||||
# else
|
||||
# define INTMAX_MAX __LONG_LONG_MAX__
|
||||
# define INTMAX_MIN __LONG_LONG_MIN__
|
||||
# endif
|
||||
# else
|
||||
typedef long intmax_t;
|
||||
# define strtoimax strtol
|
||||
# define PRIdMAX "ld"
|
||||
# define INTMAX_MAX LONG_MAX
|
||||
# define INTMAX_MIN LONG_MIN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef UINTMAX_MAX
|
||||
# if defined ULLONG_MAX || defined __LONG_LONG_MAX__
|
||||
typedef unsigned long long uintmax_t;
|
||||
# define PRIuMAX "llu"
|
||||
# else
|
||||
typedef unsigned long uintmax_t;
|
||||
# define PRIuMAX "lu"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#endif /* !defined INT32_MAX */
|
||||
#ifndef INT32_MIN
|
||||
#define INT32_MIN (-1 - INT32_MAX)
|
||||
#endif /* !defined INT32_MIN */
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#if 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
|
||||
# define ATTRIBUTE_CONST __attribute__ ((const))
|
||||
# define ATTRIBUTE_PURE __attribute__ ((__pure__))
|
||||
# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
|
||||
#else
|
||||
# define ATTRIBUTE_CONST /* empty */
|
||||
# define ATTRIBUTE_PURE /* empty */
|
||||
# define ATTRIBUTE_FORMAT(spec) /* empty */
|
||||
#endif
|
||||
|
||||
#if !defined _Noreturn && __STDC_VERSION__ < 201112
|
||||
# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__)
|
||||
# define _Noreturn __attribute__ ((__noreturn__))
|
||||
# else
|
||||
# define _Noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __STDC_VERSION__ < 199901 && !defined restrict
|
||||
# define restrict /* empty */
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Workarounds for compilers/systems.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Some time.h implementations don't declare asctime_r.
|
||||
** Others might define it as a macro.
|
||||
** Fix the former without affecting the latter.
|
||||
*/
|
||||
|
||||
#ifndef asctime_r
|
||||
extern char * asctime_r(struct tm const *, char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Compile with -Dtime_tz=T to build the tz package with a private
|
||||
** time_t type equivalent to T rather than the system-supplied time_t.
|
||||
** This debugging feature can test unusual design decisions
|
||||
** (e.g., time_t wider than 'long', or unsigned time_t) even on
|
||||
** typical platforms.
|
||||
*/
|
||||
#ifdef time_tz
|
||||
static time_t sys_time(time_t *x) { return time(x); }
|
||||
|
||||
# undef ctime
|
||||
# define ctime tz_ctime
|
||||
# undef ctime_r
|
||||
# define ctime_r tz_ctime_r
|
||||
# undef difftime
|
||||
# define difftime tz_difftime
|
||||
# undef gmtime
|
||||
# define gmtime tz_gmtime
|
||||
# undef gmtime_r
|
||||
# define gmtime_r tz_gmtime_r
|
||||
# undef localtime
|
||||
# define localtime tz_localtime
|
||||
# undef localtime_r
|
||||
# define localtime_r tz_localtime_r
|
||||
# undef mktime
|
||||
# define mktime tz_mktime
|
||||
# undef time
|
||||
# define time tz_time
|
||||
# undef time_t
|
||||
# define time_t tz_time_t
|
||||
|
||||
typedef time_tz time_t;
|
||||
|
||||
char *ctime(time_t const *);
|
||||
char *ctime_r(time_t const *, char *);
|
||||
double difftime(time_t, time_t);
|
||||
struct tm *gmtime(time_t const *);
|
||||
struct tm *gmtime_r(time_t const *restrict, struct tm *restrict);
|
||||
struct tm *localtime(time_t const *);
|
||||
struct tm *localtime_r(time_t const *restrict, struct tm *restrict);
|
||||
time_t mktime(struct tm *);
|
||||
|
||||
static time_t
|
||||
time(time_t *p)
|
||||
{
|
||||
time_t r = sys_time(0);
|
||||
if (p)
|
||||
*p = r;
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Private function declarations.
|
||||
*/
|
||||
|
||||
char * icatalloc(char * old, const char * new);
|
||||
char * icpyalloc(const char * string);
|
||||
const char * scheck(const char * string, const char * format);
|
||||
|
||||
/*
|
||||
** Finally, some convenience items.
|
||||
*/
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif /* !defined TRUE */
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif /* !defined FALSE */
|
||||
|
||||
#ifndef TYPE_BIT
|
||||
#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
|
||||
#endif /* !defined TYPE_BIT */
|
||||
|
||||
#ifndef TYPE_SIGNED
|
||||
#define TYPE_SIGNED(type) (((type) -1) < 0)
|
||||
#endif /* !defined TYPE_SIGNED */
|
||||
|
||||
/* The minimum and maximum finite time values. */
|
||||
static time_t const time_t_min =
|
||||
(TYPE_SIGNED(time_t)
|
||||
? (time_t) -1 << (CHAR_BIT * sizeof (time_t) - 1)
|
||||
: 0);
|
||||
static time_t const time_t_max =
|
||||
(TYPE_SIGNED(time_t)
|
||||
? - (~ 0 < 0) - ((time_t) -1 << (CHAR_BIT * sizeof (time_t) - 1))
|
||||
: -1);
|
||||
|
||||
#ifndef INT_STRLEN_MAXIMUM
|
||||
/*
|
||||
** 302 / 1000 is log10(2.0) rounded up.
|
||||
** Subtract one for the sign bit if the type is signed;
|
||||
** add one for integer division truncation;
|
||||
** add one more for a minus sign if the type is signed.
|
||||
*/
|
||||
#define INT_STRLEN_MAXIMUM(type) \
|
||||
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + \
|
||||
1 + TYPE_SIGNED(type))
|
||||
#endif /* !defined INT_STRLEN_MAXIMUM */
|
||||
|
||||
/*
|
||||
** INITIALIZE(x)
|
||||
*/
|
||||
|
||||
#ifndef GNUC_or_lint
|
||||
#ifdef lint
|
||||
#define GNUC_or_lint
|
||||
#endif /* defined lint */
|
||||
#ifndef lint
|
||||
#ifdef __GNUC__
|
||||
#define GNUC_or_lint
|
||||
#endif /* defined __GNUC__ */
|
||||
#endif /* !defined lint */
|
||||
#endif /* !defined GNUC_or_lint */
|
||||
|
||||
#ifndef INITIALIZE
|
||||
#ifdef GNUC_or_lint
|
||||
#define INITIALIZE(x) ((x) = 0)
|
||||
#endif /* defined GNUC_or_lint */
|
||||
#ifndef GNUC_or_lint
|
||||
#define INITIALIZE(x)
|
||||
#endif /* !defined GNUC_or_lint */
|
||||
#endif /* !defined INITIALIZE */
|
||||
|
||||
/*
|
||||
** For the benefit of GNU folk...
|
||||
** `_(MSGID)' uses the current locale's message library string for MSGID.
|
||||
** The default is to use gettext if available, and use MSGID otherwise.
|
||||
*/
|
||||
|
||||
#ifndef _
|
||||
#if HAVE_GETTEXT
|
||||
#define _(msgid) gettext(msgid)
|
||||
#else /* !HAVE_GETTEXT */
|
||||
#define _(msgid) msgid
|
||||
#endif /* !HAVE_GETTEXT */
|
||||
#endif /* !defined _ */
|
||||
|
||||
#ifndef TZ_DOMAIN
|
||||
#define TZ_DOMAIN "tz"
|
||||
#endif /* !defined TZ_DOMAIN */
|
||||
|
||||
#if HAVE_INCOMPATIBLE_CTIME_R
|
||||
#undef asctime_r
|
||||
#undef ctime_r
|
||||
char *asctime_r(struct tm const *, char *);
|
||||
char *ctime_r(time_t const *, char *);
|
||||
#endif /* HAVE_INCOMPATIBLE_CTIME_R */
|
||||
|
||||
#ifndef YEARSPERREPEAT
|
||||
#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
|
||||
#endif /* !defined YEARSPERREPEAT */
|
||||
|
||||
/*
|
||||
** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
|
||||
*/
|
||||
|
||||
#ifndef AVGSECSPERYEAR
|
||||
#define AVGSECSPERYEAR 31556952L
|
||||
#endif /* !defined AVGSECSPERYEAR */
|
||||
|
||||
#ifndef SECSPERREPEAT
|
||||
#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
|
||||
#endif /* !defined SECSPERREPEAT */
|
||||
|
||||
#ifndef SECSPERREPEAT_BITS
|
||||
#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
|
||||
#endif /* !defined SECSPERREPEAT_BITS */
|
||||
|
||||
/*
|
||||
** UNIX was a registered trademark of The Open Group in 2003.
|
||||
*/
|
||||
|
||||
#endif /* !defined PRIVATE_H */
|
||||
95
intl/icu/source/tools/tzcode/readme.txt
Normal file
95
intl/icu/source/tools/tzcode/readme.txt
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
* Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
* License & terms of use: http://www.unicode.org/copyright.html
|
||||
**********************************************************************
|
||||
* Copyright (c) 2003-2014, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
* Created: August 18 2003
|
||||
* Since: ICU 2.8
|
||||
**********************************************************************
|
||||
|
||||
Note: this directory currently contains tzcode as of tzcode2014b.tar.gz
|
||||
with localtime.c patches from tzcode2014b.tar.gz
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
OVERVIEW
|
||||
|
||||
This file describes the tools in icu/source/tools/tzcode
|
||||
|
||||
The purpose of these tools is to process the zoneinfo or "Olson" time
|
||||
zone database into a form usable by ICU4C (release 2.8 and later).
|
||||
Unlike earlier releases, ICU4C 2.8 supports historical time zone
|
||||
behavior, as well as the full set of Olson compatibility IDs.
|
||||
|
||||
References:
|
||||
|
||||
ICU4C: http://www.icu-project.org/
|
||||
Olson: ftp://ftp.iana.org/tz/releases/
|
||||
|
||||
----------------------------------------------------------------------
|
||||
ICU4C vs. ICU4J
|
||||
|
||||
For ICU releases >= 2.8, both ICU4C and ICU4J implement full
|
||||
historical time zones, based on Olson data. The implementations in C
|
||||
and Java are somewhat different. The C implementation is a
|
||||
self-contained implementation, whereas ICU4J uses the underlying JDK
|
||||
1.3 or 1.4 time zone implementation.
|
||||
|
||||
Older versions of ICU (C and Java <= 2.6) implement a "present day
|
||||
snapshot". This only reflects current time zone behavior, without
|
||||
historical variation. Furthermore, it lacks the full set of Olson
|
||||
compatibility IDs.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
BACKGROUND
|
||||
|
||||
The zoneinfo or "Olson" time zone package is used by various systems
|
||||
to describe the behavior of time zones. The package consists of
|
||||
several parts. E.g.:
|
||||
|
||||
Index of ftp://ftp.iana.org/tz/releases/
|
||||
|
||||
tzcode2014b.tar.gz 172 KB 3/25/2014 05:11:00 AM
|
||||
tzdata2014b.tar.gz 216 KB 3/25/2014 05:11:00 AM
|
||||
|
||||
ICU only uses the tzdataYYYYV.tar.gz files,
|
||||
where YYYY is the year and V is the version letter ('a'...'z').
|
||||
|
||||
This directory has partial contents of tzcode checked into ICU
|
||||
|
||||
----------------------------------------------------------------------
|
||||
HOWTO
|
||||
|
||||
0. Note, these instructions will only work on POSIX type systems.
|
||||
|
||||
1. Obtain the current versions of tzdataYYYYV.tar.gz (aka `tzdata') from
|
||||
the FTP site given above. Either manually download or use wget:
|
||||
|
||||
$ cd {path_to}/icu/source/tools/tzcode
|
||||
$ wget "ftp://ftp.iana.org/tz/releases/tzdata*.tar.gz"
|
||||
|
||||
2. Copy only one tzdata*.tar.gz file into the icu/source/tools/tzcode/
|
||||
directory (this directory).
|
||||
|
||||
*** Make sure you only have ONE FILE named tzdata*.tar.gz in the
|
||||
directory.
|
||||
|
||||
3. Build ICU normally. You will see a notice "updating zoneinfo.txt..."
|
||||
|
||||
### Following instructions for ICU maintainers only ###
|
||||
|
||||
4. Obtain the current version of tzcodeYYYY.tar.gz from the FTP site to
|
||||
this directory.
|
||||
|
||||
5. Run make target "check-dump". This target extract makes the original
|
||||
tzcode and compile the original tzdata with icu supplemental data
|
||||
(icuzones). Then it makes zdump / icuzdump and dump all time
|
||||
transitions for all ICU timezone to files under zdumpout / icuzdumpout
|
||||
directory. When they produce different results, the target returns
|
||||
the error.
|
||||
|
||||
6. Don't forget to check in the new zoneinfo64.txt (from its location at
|
||||
{path_to}/icu/source/data/misc/zoneinfo64.txt) into SVN.
|
||||
|
||||
64
intl/icu/source/tools/tzcode/scheck.c
Normal file
64
intl/icu/source/tools/tzcode/scheck.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 2006-07-17 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*LINTLIBRARY*/
|
||||
|
||||
#include "private.h"
|
||||
|
||||
const char *
|
||||
scheck(const char *const string, const char *const format)
|
||||
{
|
||||
register char * fbuf;
|
||||
register const char * fp;
|
||||
register char * tp;
|
||||
register int c;
|
||||
register const char * result;
|
||||
char dummy;
|
||||
|
||||
result = "";
|
||||
if (string == NULL || format == NULL)
|
||||
return result;
|
||||
fbuf = malloc(2 * strlen(format) + 4);
|
||||
if (fbuf == NULL)
|
||||
return result;
|
||||
fp = format;
|
||||
tp = fbuf;
|
||||
|
||||
/*
|
||||
** Copy directives, suppressing each conversion that is not
|
||||
** already suppressed. Scansets containing '%' are not
|
||||
** supported; e.g., the conversion specification "%[%]" is not
|
||||
** supported. Also, multibyte characters containing a
|
||||
** non-leading '%' byte are not supported.
|
||||
*/
|
||||
while ((*tp++ = c = *fp++) != '\0') {
|
||||
if (c != '%')
|
||||
continue;
|
||||
if (is_digit(*fp)) {
|
||||
char const *f = fp;
|
||||
char *t = tp;
|
||||
do {
|
||||
*t++ = c = *f++;
|
||||
} while (is_digit(c));
|
||||
if (c == '$') {
|
||||
fp = f;
|
||||
tp = t;
|
||||
}
|
||||
}
|
||||
*tp++ = '*';
|
||||
if (*fp == '*')
|
||||
++fp;
|
||||
if ((*tp++ = *fp++) == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
*(tp - 1) = '%';
|
||||
*tp++ = 'c';
|
||||
*tp = '\0';
|
||||
if (sscanf(string, fbuf, &dummy) != 1)
|
||||
result = format;
|
||||
free(fbuf);
|
||||
return result;
|
||||
}
|
||||
1807
intl/icu/source/tools/tzcode/tz2icu.cpp
Normal file
1807
intl/icu/source/tools/tzcode/tz2icu.cpp
Normal file
File diff suppressed because it is too large
Load diff
46
intl/icu/source/tools/tzcode/tz2icu.h
Normal file
46
intl/icu/source/tools/tzcode/tz2icu.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2003-2013, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Alan Liu
|
||||
* Created: July 10 2003
|
||||
* Since: ICU 2.8
|
||||
**********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _TZ2ICU_H_
|
||||
#define _TZ2ICU_H_
|
||||
|
||||
/* We have modified the zoneinfo binary format (we write raw offset
|
||||
* and DST offset separately instead of their sum) so we notate the
|
||||
* file with a distinct signature. This prevents someone from trying
|
||||
* to use our output files as normal zoneinfo files, and also prevents
|
||||
* someone from trying to use normal zoneinfo files for ICU. We also
|
||||
* use the first byte of the reserved section as a version integer, to
|
||||
* be incremented each time the data format changes.
|
||||
*/
|
||||
|
||||
#define TZ_ICU_MAGIC "TZic" /* cf. TZ_MAGIC = "TZif" */
|
||||
|
||||
typedef unsigned char ICUZoneinfoVersion;
|
||||
|
||||
#define TZ_ICU_VERSION ((ICUZoneinfoVersion) 1)
|
||||
|
||||
/* File into which we will write supplemental ICU data. This allows
|
||||
* zic to communicate final zone data to tz2icu. */
|
||||
#define ICU_ZONE_FILE "icu_zone.txt"
|
||||
|
||||
/* Output resource name. This determines both the file name and the
|
||||
* resource name within the file. That is, the output will be to the
|
||||
* file ICU_TZ_RESOURCE ".txt" and the resource within it will be
|
||||
* ICU_TZ_RESOURCE. */
|
||||
#define ICU_TZ_RESOURCE_OLD "zoneinfo"
|
||||
#define ICU_TZ_RESOURCE "zoneinfo64"
|
||||
|
||||
/* File containinng custom zone-region mapping. */
|
||||
#define ICU_REGIONS "icuregions"
|
||||
|
||||
#endif
|
||||
169
intl/icu/source/tools/tzcode/tzfile.h
Normal file
169
intl/icu/source/tools/tzcode/tzfile.h
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
#ifndef TZFILE_H
|
||||
|
||||
#define TZFILE_H
|
||||
|
||||
/*
|
||||
** This file is in the public domain, so clarified as of
|
||||
** 1996-06-05 by Arthur David Olson.
|
||||
*/
|
||||
|
||||
/*
|
||||
** This header is for use ONLY with the time conversion code.
|
||||
** There is no guarantee that it will remain unchanged,
|
||||
** or that it will remain at all.
|
||||
** Do NOT copy it to any system include directory.
|
||||
** Thank you!
|
||||
*/
|
||||
|
||||
/*
|
||||
** Information about time zone files.
|
||||
*/
|
||||
|
||||
#ifndef TZDIR
|
||||
#define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
|
||||
#endif /* !defined TZDIR */
|
||||
|
||||
#ifndef TZDEFAULT
|
||||
#define TZDEFAULT "localtime"
|
||||
#endif /* !defined TZDEFAULT */
|
||||
|
||||
#ifndef TZDEFRULES
|
||||
#define TZDEFRULES "posixrules"
|
||||
#endif /* !defined TZDEFRULES */
|
||||
|
||||
/*
|
||||
** Each file begins with. . .
|
||||
*/
|
||||
|
||||
#define TZ_MAGIC "TZif"
|
||||
|
||||
struct tzhead {
|
||||
char tzh_magic[4]; /* TZ_MAGIC */
|
||||
char tzh_version[1]; /* '\0' or '2' or '3' as of 2013 */
|
||||
char tzh_reserved[15]; /* reserved--must be zero */
|
||||
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
|
||||
char tzh_leapcnt[4]; /* coded number of leap seconds */
|
||||
char tzh_timecnt[4]; /* coded number of transition times */
|
||||
char tzh_typecnt[4]; /* coded number of local time types */
|
||||
char tzh_charcnt[4]; /* coded number of abbr. chars */
|
||||
};
|
||||
|
||||
/*
|
||||
** . . .followed by. . .
|
||||
**
|
||||
** tzh_timecnt (char [4])s coded transition times a la time(2)
|
||||
** tzh_timecnt (unsigned char)s types of local time starting at above
|
||||
** tzh_typecnt repetitions of
|
||||
** one (char [4]) coded UT offset in seconds
|
||||
** one (unsigned char) used to set tm_isdst
|
||||
** one (unsigned char) that's an abbreviation list index
|
||||
** tzh_charcnt (char)s '\0'-terminated zone abbreviations
|
||||
** tzh_leapcnt repetitions of
|
||||
** one (char [4]) coded leap second transition times
|
||||
** one (char [4]) total correction after above
|
||||
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
|
||||
** time is standard time, if FALSE,
|
||||
** transition time is wall clock time
|
||||
** if absent, transition times are
|
||||
** assumed to be wall clock time
|
||||
** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
|
||||
** time is UT, if FALSE,
|
||||
** transition time is local time
|
||||
** if absent, transition times are
|
||||
** assumed to be local time
|
||||
*/
|
||||
|
||||
/*
|
||||
** If tzh_version is '2' or greater, the above is followed by a second instance
|
||||
** of tzhead and a second instance of the data in which each coded transition
|
||||
** time uses 8 rather than 4 chars,
|
||||
** then a POSIX-TZ-environment-variable-style string for use in handling
|
||||
** instants after the last transition time stored in the file
|
||||
** (with nothing between the newlines if there is no POSIX representation for
|
||||
** such instants).
|
||||
**
|
||||
** If tz_version is '3' or greater, the above is extended as follows.
|
||||
** First, the POSIX TZ string's hour offset may range from -167
|
||||
** through 167 as compared to the POSIX-required 0 through 24.
|
||||
** Second, its DST start time may be January 1 at 00:00 and its stop
|
||||
** time December 31 at 24:00 plus the difference between DST and
|
||||
** standard time, indicating DST all year.
|
||||
*/
|
||||
|
||||
/*
|
||||
** In the current implementation, "tzset()" refuses to deal with files that
|
||||
** exceed any of the limits below.
|
||||
*/
|
||||
|
||||
#ifndef TZ_MAX_TIMES
|
||||
#define TZ_MAX_TIMES 2000
|
||||
#endif /* !defined TZ_MAX_TIMES */
|
||||
|
||||
#ifndef TZ_MAX_TYPES
|
||||
/* This must be at least 17 for Europe/Samara and Europe/Vilnius. */
|
||||
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
|
||||
#endif /* !defined TZ_MAX_TYPES */
|
||||
|
||||
#ifndef TZ_MAX_CHARS
|
||||
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
|
||||
/* (limited by what unsigned chars can hold) */
|
||||
#endif /* !defined TZ_MAX_CHARS */
|
||||
|
||||
#ifndef TZ_MAX_LEAPS
|
||||
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
|
||||
#endif /* !defined TZ_MAX_LEAPS */
|
||||
|
||||
#define SECSPERMIN 60
|
||||
#define MINSPERHOUR 60
|
||||
#define HOURSPERDAY 24
|
||||
#define DAYSPERWEEK 7
|
||||
#define DAYSPERNYEAR 365
|
||||
#define DAYSPERLYEAR 366
|
||||
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
||||
#define SECSPERDAY ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
|
||||
#define MONSPERYEAR 12
|
||||
|
||||
#define TM_SUNDAY 0
|
||||
#define TM_MONDAY 1
|
||||
#define TM_TUESDAY 2
|
||||
#define TM_WEDNESDAY 3
|
||||
#define TM_THURSDAY 4
|
||||
#define TM_FRIDAY 5
|
||||
#define TM_SATURDAY 6
|
||||
|
||||
#define TM_JANUARY 0
|
||||
#define TM_FEBRUARY 1
|
||||
#define TM_MARCH 2
|
||||
#define TM_APRIL 3
|
||||
#define TM_MAY 4
|
||||
#define TM_JUNE 5
|
||||
#define TM_JULY 6
|
||||
#define TM_AUGUST 7
|
||||
#define TM_SEPTEMBER 8
|
||||
#define TM_OCTOBER 9
|
||||
#define TM_NOVEMBER 10
|
||||
#define TM_DECEMBER 11
|
||||
|
||||
#define TM_YEAR_BASE 1900
|
||||
|
||||
#define EPOCH_YEAR 1970
|
||||
#define EPOCH_WDAY TM_THURSDAY
|
||||
|
||||
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
||||
|
||||
/*
|
||||
** Since everything in isleap is modulo 400 (or a factor of 400), we know that
|
||||
** isleap(y) == isleap(y % 400)
|
||||
** and so
|
||||
** isleap(a + b) == isleap((a + b) % 400)
|
||||
** or
|
||||
** isleap(a + b) == isleap(a % 400 + b % 400)
|
||||
** This is true even if % means modulo rather than Fortran remainder
|
||||
** (which is allowed by C89 but not C99).
|
||||
** We use this to avoid addition overflow problems.
|
||||
*/
|
||||
|
||||
#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
|
||||
|
||||
#endif /* !defined TZFILE_H */
|
||||
308
intl/icu/source/tools/tzcode/tzselect.ksh
Normal file
308
intl/icu/source/tools/tzcode/tzselect.ksh
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
#! /bin/ksh
|
||||
|
||||
# '@(#)tzselect.ksh 8.1'
|
||||
|
||||
# Ask the user about the time zone, and output the resulting TZ value to stdout.
|
||||
# Interact with the user via stderr and stdin.
|
||||
|
||||
# Contributed by Paul Eggert.
|
||||
|
||||
# Porting notes:
|
||||
#
|
||||
# This script requires several features of the Korn shell.
|
||||
# If your host lacks the Korn shell,
|
||||
# you can use either of the following free programs instead:
|
||||
#
|
||||
# <a href=ftp://ftp.gnu.org/pub/gnu/>
|
||||
# Bourne-Again shell (bash)
|
||||
# </a>
|
||||
#
|
||||
# <a href=ftp://ftp.cs.mun.ca/pub/pdksh/pdksh.tar.gz>
|
||||
# Public domain ksh
|
||||
# </a>
|
||||
#
|
||||
# This script also uses several features of modern awk programs.
|
||||
# If your host lacks awk, or has an old awk that does not conform to Posix.2,
|
||||
# you can use either of the following free programs instead:
|
||||
#
|
||||
# <a href=ftp://ftp.gnu.org/pub/gnu/>
|
||||
# GNU awk (gawk)
|
||||
# </a>
|
||||
#
|
||||
# <a href=ftp://ftp.whidbey.net/pub/brennan/>
|
||||
# mawk
|
||||
# </a>
|
||||
|
||||
|
||||
# Specify default values for environment variables if they are unset.
|
||||
: ${AWK=awk}
|
||||
: ${TZDIR=$(pwd)}
|
||||
|
||||
# Check for awk Posix compliance.
|
||||
($AWK -v x=y 'BEGIN { exit 123 }') </dev/null >/dev/null 2>&1
|
||||
[ $? = 123 ] || {
|
||||
echo >&2 "$0: Sorry, your \`$AWK' program is not Posix compatible."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Make sure the tables are readable.
|
||||
TZ_COUNTRY_TABLE=$TZDIR/iso3166.tab
|
||||
TZ_ZONE_TABLE=$TZDIR/zone.tab
|
||||
for f in $TZ_COUNTRY_TABLE $TZ_ZONE_TABLE
|
||||
do
|
||||
<$f || {
|
||||
echo >&2 "$0: time zone files are not set up correctly"
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
newline='
|
||||
'
|
||||
IFS=$newline
|
||||
|
||||
|
||||
# Work around a bug in bash 1.14.7 and earlier, where $PS3 is sent to stdout.
|
||||
case $(echo 1 | (select x in x; do break; done) 2>/dev/null) in
|
||||
?*) PS3=
|
||||
esac
|
||||
|
||||
|
||||
# Begin the main loop. We come back here if the user wants to retry.
|
||||
while
|
||||
|
||||
echo >&2 'Please identify a location' \
|
||||
'so that time zone rules can be set correctly.'
|
||||
|
||||
continent=
|
||||
country=
|
||||
region=
|
||||
|
||||
|
||||
# Ask the user for continent or ocean.
|
||||
|
||||
echo >&2 'Please select a continent or ocean.'
|
||||
|
||||
select continent in \
|
||||
Africa \
|
||||
Americas \
|
||||
Antarctica \
|
||||
'Arctic Ocean' \
|
||||
Asia \
|
||||
'Atlantic Ocean' \
|
||||
Australia \
|
||||
Europe \
|
||||
'Indian Ocean' \
|
||||
'Pacific Ocean' \
|
||||
'none - I want to specify the time zone using the Posix TZ format.'
|
||||
do
|
||||
case $continent in
|
||||
'')
|
||||
echo >&2 'Please enter a number in range.';;
|
||||
?*)
|
||||
case $continent in
|
||||
Americas) continent=America;;
|
||||
*' '*) continent=$(expr "$continent" : '\([^ ]*\)')
|
||||
esac
|
||||
break
|
||||
esac
|
||||
done
|
||||
case $continent in
|
||||
'')
|
||||
exit 1;;
|
||||
none)
|
||||
# Ask the user for a Posix TZ string. Check that it conforms.
|
||||
while
|
||||
echo >&2 'Please enter the desired value' \
|
||||
'of the TZ environment variable.'
|
||||
echo >&2 'For example, GST-10 is a zone named GST' \
|
||||
'that is 10 hours ahead (east) of UTC.'
|
||||
read TZ
|
||||
$AWK -v TZ="$TZ" 'BEGIN {
|
||||
tzname = "[^-+,0-9][^-+,0-9][^-+,0-9]+"
|
||||
time = "[0-2]?[0-9](:[0-5][0-9](:[0-5][0-9])?)?"
|
||||
offset = "[-+]?" time
|
||||
date = "(J?[0-9]+|M[0-9]+\.[0-9]+\.[0-9]+)"
|
||||
datetime = "," date "(/" time ")?"
|
||||
tzpattern = "^(:.*|" tzname offset "(" tzname \
|
||||
"(" offset ")?(" datetime datetime ")?)?)$"
|
||||
if (TZ ~ tzpattern) exit 1
|
||||
exit 0
|
||||
}'
|
||||
do
|
||||
echo >&2 "\`$TZ' is not a conforming" \
|
||||
'Posix time zone string.'
|
||||
done
|
||||
TZ_for_date=$TZ;;
|
||||
*)
|
||||
# Get list of names of countries in the continent or ocean.
|
||||
countries=$($AWK -F'\t' \
|
||||
-v continent="$continent" \
|
||||
-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
|
||||
'
|
||||
/^#/ { next }
|
||||
$3 ~ ("^" continent "/") {
|
||||
if (!cc_seen[$1]++) cc_list[++ccs] = $1
|
||||
}
|
||||
END {
|
||||
while (getline <TZ_COUNTRY_TABLE) {
|
||||
if ($0 !~ /^#/) cc_name[$1] = $2
|
||||
}
|
||||
for (i = 1; i <= ccs; i++) {
|
||||
country = cc_list[i]
|
||||
if (cc_name[country]) {
|
||||
country = cc_name[country]
|
||||
}
|
||||
print country
|
||||
}
|
||||
}
|
||||
' <$TZ_ZONE_TABLE | sort -f)
|
||||
|
||||
|
||||
# If there's more than one country, ask the user which one.
|
||||
case $countries in
|
||||
*"$newline"*)
|
||||
echo >&2 'Please select a country.'
|
||||
select country in $countries
|
||||
do
|
||||
case $country in
|
||||
'') echo >&2 'Please enter a number in range.';;
|
||||
?*) break
|
||||
esac
|
||||
done
|
||||
|
||||
case $country in
|
||||
'') exit 1
|
||||
esac;;
|
||||
*)
|
||||
country=$countries
|
||||
esac
|
||||
|
||||
|
||||
# Get list of names of time zone rule regions in the country.
|
||||
regions=$($AWK -F'\t' \
|
||||
-v country="$country" \
|
||||
-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
|
||||
'
|
||||
BEGIN {
|
||||
cc = country
|
||||
while (getline <TZ_COUNTRY_TABLE) {
|
||||
if ($0 !~ /^#/ && country == $2) {
|
||||
cc = $1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
$1 == cc { print $4 }
|
||||
' <$TZ_ZONE_TABLE)
|
||||
|
||||
|
||||
# If there's more than one region, ask the user which one.
|
||||
case $regions in
|
||||
*"$newline"*)
|
||||
echo >&2 'Please select one of the following' \
|
||||
'time zone regions.'
|
||||
select region in $regions
|
||||
do
|
||||
case $region in
|
||||
'') echo >&2 'Please enter a number in range.';;
|
||||
?*) break
|
||||
esac
|
||||
done
|
||||
case $region in
|
||||
'') exit 1
|
||||
esac;;
|
||||
*)
|
||||
region=$regions
|
||||
esac
|
||||
|
||||
# Determine TZ from country and region.
|
||||
TZ=$($AWK -F'\t' \
|
||||
-v country="$country" \
|
||||
-v region="$region" \
|
||||
-v TZ_COUNTRY_TABLE="$TZ_COUNTRY_TABLE" \
|
||||
'
|
||||
BEGIN {
|
||||
cc = country
|
||||
while (getline <TZ_COUNTRY_TABLE) {
|
||||
if ($0 !~ /^#/ && country == $2) {
|
||||
cc = $1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
$1 == cc && $4 == region { print $3 }
|
||||
' <$TZ_ZONE_TABLE)
|
||||
|
||||
# Make sure the corresponding zoneinfo file exists.
|
||||
TZ_for_date=$TZDIR/$TZ
|
||||
<$TZ_for_date || {
|
||||
echo >&2 "$0: time zone files are not set up correctly"
|
||||
exit 1
|
||||
}
|
||||
esac
|
||||
|
||||
|
||||
# Use the proposed TZ to output the current date relative to UTC.
|
||||
# Loop until they agree in seconds.
|
||||
# Give up after 8 unsuccessful tries.
|
||||
|
||||
extra_info=
|
||||
for i in 1 2 3 4 5 6 7 8
|
||||
do
|
||||
TZdate=$(LANG=C TZ="$TZ_for_date" date)
|
||||
UTdate=$(LANG=C TZ=UTC0 date)
|
||||
TZsec=$(expr "$TZdate" : '.*:\([0-5][0-9]\)')
|
||||
UTsec=$(expr "$UTdate" : '.*:\([0-5][0-9]\)')
|
||||
case $TZsec in
|
||||
$UTsec)
|
||||
extra_info="
|
||||
Local time is now: $TZdate.
|
||||
Universal Time is now: $UTdate."
|
||||
break
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# Output TZ info and ask the user to confirm.
|
||||
|
||||
echo >&2 ""
|
||||
echo >&2 "The following information has been given:"
|
||||
echo >&2 ""
|
||||
case $country+$region in
|
||||
?*+?*) echo >&2 " $country$newline $region";;
|
||||
?*+) echo >&2 " $country";;
|
||||
+) echo >&2 " TZ='$TZ'"
|
||||
esac
|
||||
echo >&2 ""
|
||||
echo >&2 "Therefore TZ='$TZ' will be used.$extra_info"
|
||||
echo >&2 "Is the above information OK?"
|
||||
|
||||
ok=
|
||||
select ok in Yes No
|
||||
do
|
||||
case $ok in
|
||||
'') echo >&2 'Please enter 1 for Yes, or 2 for No.';;
|
||||
?*) break
|
||||
esac
|
||||
done
|
||||
case $ok in
|
||||
'') exit 1;;
|
||||
Yes) break
|
||||
esac
|
||||
do :
|
||||
done
|
||||
|
||||
case $SHELL in
|
||||
*csh) file=.login line="setenv TZ '$TZ'";;
|
||||
*) file=.profile line="TZ='$TZ'; export TZ"
|
||||
esac
|
||||
|
||||
echo >&2 "
|
||||
You can make this change permanent for yourself by appending the line
|
||||
$line
|
||||
to the file '$file' in your home directory; then log out and log in again.
|
||||
|
||||
Here is that TZ value again, this time on standard output so that you
|
||||
can use the $0 command in shell scripts:"
|
||||
|
||||
echo "$TZ"
|
||||
1095
intl/icu/source/tools/tzcode/zdump.c
Normal file
1095
intl/icu/source/tools/tzcode/zdump.c
Normal file
File diff suppressed because it is too large
Load diff
3155
intl/icu/source/tools/tzcode/zic.c
Normal file
3155
intl/icu/source/tools/tzcode/zic.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue