w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

tz2icu.cpp File Reference
#include "tzfile.h"
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <algorithm>
#include <cassert>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "tz2icu.h"
#include "unicode/uversion.h"
Include dependency graph for tz2icu.cpp:

Go to the source code of this file.

Classes

struct  Transition
 
struct  ZoneType
 
struct  ZoneInfo
 
struct  FinalZone
 
struct  FinalRulePart
 
struct  FinalRule
 
struct  SimplifiedZoneType
 

Macros

#define ICU_ZONE_OVERRIDE_SUFFIX   "--ICU"
 
#define ICU_ZONE_OVERRIDE_SUFFIX_LEN   5
 

Typedefs

typedef map< string, ZoneInfoZoneMap
 
typedef ZoneMap::const_iterator ZoneMapIter
 

Enumerations

enum  { DOM = 0 , DOWGEQ = 1 , DOWLEQ = 2 }
 

Functions

Bool__ isLeap (int32_t y)
 
int64_t secsPerYear (int32_t y)
 
int64_t yearToSeconds (int32_t year)
 
int32_t secondsToYear (int64_t seconds)
 
int64_t readcoded (ifstream &file, int64_t minv=numeric_limits< int64_t >::min(), int64_t maxv=numeric_limits< int64_t >::max())
 
int64_t readcoded64 (ifstream &file, int64_t minv=numeric_limits< int64_t >::min(), int64_t maxv=numeric_limits< int64_t >::max())
 
Bool__ readbool (ifstream &file)
 
void readzoneinfo (ifstream &file, ZoneInfo &info, Bool__ is64bitData)
 
void handleFile (string path, string id)
 
void scandir (string dir, string prefix="")
 
void consumeLine (istream &in)
 
Bool__ isNotSet (const pair< const string, FinalRule > &p)
 
Bool__ mapsToUnknownRule (const pair< const string, FinalZone > &p)
 
void insertRuleID (const pair< string, FinalRule > &p)
 
void eraseRuleID (const pair< string, FinalZone > &p)
 
void readFinalZonesAndRules (istream &in)
 
ostream & operator<< (ostream &os, const ZoneMap &zoneinfo)
 
ostream & printStringList (ostream &os, const ZoneMap &zoneinfo)
 
Bool__ isAfter (const Transition t, int64_t thresh)
 
void mergeOne (const string &zoneid, const FinalZone &fz)
 
void mergeFinalZone (const pair< string, FinalZone > &p)
 
int main (int argc, char *argv[])
 

Variables

Bool__ ICU44PLUS = 1
 
string TZ_RESOURCE_NAME = "zoneinfo64"
 
const int64_t SECS_PER_YEAR = 31536000
 
const int64_t SECS_PER_LEAP_YEAR = 31622400
 
const int64_t LOWEST_TIME32 = (int64_t)((int32_t)0x80000000)
 
const int64_t HIGHEST_TIME32 = (int64_t)((int32_t)0x7fffffff)
 
ZoneMap ZONEINFO
 
const char * TIME_MODE [] = {"w", "s", "u"}
 
const int32_t MONTH_LEN [] = {31,29,31,30,31,30,31,31,30,31,30,31}
 
const int32_t HOUR = 3600
 
map< string, FinalZonefinalZones
 
map< string, FinalRulefinalRules
 
map< string, set< string > > links
 
map< string, stringreverseLinks
 
set< stringruleIDset
 

Macro Definition Documentation

◆ ICU_ZONE_OVERRIDE_SUFFIX

#define ICU_ZONE_OVERRIDE_SUFFIX   "--ICU"

Definition at line 1429 of file tz2icu.cpp.

◆ ICU_ZONE_OVERRIDE_SUFFIX_LEN

#define ICU_ZONE_OVERRIDE_SUFFIX_LEN   5

Definition at line 1430 of file tz2icu.cpp.

Typedef Documentation

◆ ZoneMap

Definition at line 225 of file tz2icu.cpp.

◆ ZoneMapIter

typedef ZoneMap::const_iterator ZoneMapIter

Definition at line 227 of file tz2icu.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DOM 
DOWGEQ 
DOWLEQ 

Definition at line 718 of file tz2icu.cpp.

Function Documentation

◆ consumeLine()

void consumeLine ( istream &  in)

Read and discard the current line.

Definition at line 711 of file tz2icu.cpp.

References c, EOF, and in.

Referenced by readFinalZonesAndRules().

◆ eraseRuleID()

void eraseRuleID ( const pair< string, FinalZone > &  p)

Definition at line 935 of file tz2icu.cpp.

References p, and ruleIDset.

Referenced by readFinalZonesAndRules().

◆ handleFile()

void handleFile ( string  path,
string  id 
)

Process a single zoneinfo file, adding the data to ZONEINFO

Parameters
paththe full path to the file, e.g., ".\zoneinfo\America\Los_Angeles"
idthe zone ID, e.g., "America/Los_Angeles"

Definition at line 537 of file tz2icu.cpp.

References binary, ch, end, file, id, in, info, int64_t, readzoneinfo(), and ZONEINFO.

Referenced by scandir().

◆ insertRuleID()

void insertRuleID ( const pair< string, FinalRule > &  p)

Definition at line 931 of file tz2icu.cpp.

References p, and ruleIDset.

Referenced by readFinalZonesAndRules().

◆ isAfter()

Bool__ isAfter ( const Transition  t,
int64_t  thresh 
)

Definition at line 1194 of file tz2icu.cpp.

References thresh.

Referenced by ZoneInfo::mergeFinalData(), and graphite2::ShiftCollider::mergeSlot().

◆ isLeap()

Bool__ isLeap ( int32_t  y)

Definition at line 66 of file tz2icu.cpp.

References y.

Referenced by Grego::dayToFields(), HebrewCalendar::handleComputeFields(), and secsPerYear().

◆ isNotSet()

Bool__ isNotSet ( const pair< const string, FinalRule > &  p)

Predicate used to find FinalRule objects that do not have both sub-parts set (indicating an error in the input file).

Definition at line 911 of file tz2icu.cpp.

References p.

Referenced by readFinalZonesAndRules().

◆ main()

◆ mapsToUnknownRule()

Bool__ mapsToUnknownRule ( const pair< const string, FinalZone > &  p)

Predicate used to find FinalZone objects that do not map to a known rule (indicating an error in the input file).

Definition at line 919 of file tz2icu.cpp.

References finalRules, and p.

Referenced by readFinalZonesAndRules().

◆ mergeFinalZone()

void mergeFinalZone ( const pair< string, FinalZone > &  p)

Visitor function that merges the final zone data into the main zone data structures. It calls mergeOne for each final zone and its list of aliases.

Definition at line 1401 of file tz2icu.cpp.

References mergeOne(), and p.

Referenced by main().

◆ mergeOne()

void mergeOne ( const string zoneid,
const FinalZone fz 
)

Merge the data from the given final zone into the core zone data by calling the ZoneInfo member function mergeFinalData.

Definition at line 1389 of file tz2icu.cpp.

References ZONEINFO.

Referenced by mergeFinalZone().

◆ operator<<()

ostream& operator<< ( ostream &  os,
const ZoneMap zoneinfo 
)
inline

Definition at line 1147 of file tz2icu.cpp.

References c, and ICU44PLUS.

◆ printStringList()

ostream& printStringList ( ostream &  os,
const ZoneMap zoneinfo 
)

Definition at line 1161 of file tz2icu.cpp.

References col, and n.

Referenced by main().

◆ readbool()

Bool__ readbool ( ifstream &  file)

Definition at line 277 of file tz2icu.cpp.

References c, and int32_t.

Referenced by readzoneinfo().

◆ readcoded()

int64_t readcoded ( ifstream &  file,
int64_t  minv = numeric_limits<int64_t>::min(),
int64_t  maxv = numeric_limits<int64_t>::max() 
)

Definition at line 241 of file tz2icu.cpp.

References buf, i, shift, and val.

Referenced by readzoneinfo().

◆ readcoded64()

int64_t readcoded64 ( ifstream &  file,
int64_t  minv = numeric_limits<int64_t>::min(),
int64_t  maxv = numeric_limits<int64_t>::max() 
)

Definition at line 259 of file tz2icu.cpp.

References buf, i, int64_t, shift, and val.

Referenced by readzoneinfo().

◆ readFinalZonesAndRules()

void readFinalZonesAndRules ( istream &  in)

Populate finalZones and finalRules from the given istream.

Definition at line 942 of file tz2icu.cpp.

References consumeLine(), eraseRuleID(), finalRules, finalZones, id, in, insertRuleID(), isNotSet(), FinalRulePart::isset, links, mapsToUnknownRule(), mode, month, offset, p, FinalRule::part, reverseLinks, ruleIDset, FinalRulePart::set(), time(), and year.

Referenced by main().

◆ readzoneinfo()

void readzoneinfo ( ifstream &  file,
ZoneInfo info,
Bool__  is64bitData 
)

Read the zoneinfo file structure (see tzfile.h) into a ZoneInfo

Parameters
filean already-open file stream

Definition at line 292 of file tz2icu.cpp.

References assert(), buf, c, charcnt, find(), HIGHEST_TIME32, i, ICU44PLUS, ii, index, info, int32_t, leapcnt, limit, LOWEST_TIME32, p, readbool(), readcoded(), readcoded64(), start, str, strncmp(), t, timecnt, type, typecnt, TZ_ICU_MAGIC, TZ_ICU_VERSION, cordic::x, and y.

Referenced by handleFile().

◆ scandir()

void scandir ( string  dir,
string  prefix = "" 
)

Recursively scan the given directory, calling handleFile() for each file in the tree. The user should call with the root directory and a prefix of "". The function will call itself with non-empty prefix values.

Definition at line 645 of file tz2icu.cpp.

References chdir, closedir(), dir, dir_entry, dp, e, exit(), getcwd, handleFile(), i, int32_t, lstat(), name, NULL, opendir(), readdir(), and S_ISDIR.

Referenced by main().

◆ secondsToYear()

int32_t secondsToYear ( int64_t  seconds)

Given 1970 GMT epoch seconds, return the calendar year containing that time. secondsToYear(0) == 1970.

Definition at line 95 of file tz2icu.cpp.

References s, seconds, secsPerYear(), and y.

◆ secsPerYear()

int64_t secsPerYear ( int32_t  y)

Definition at line 70 of file tz2icu.cpp.

References isLeap(), SECS_PER_LEAP_YEAR, SECS_PER_YEAR, and y.

Referenced by secondsToYear(), and yearToSeconds().

◆ yearToSeconds()

int64_t yearToSeconds ( int32_t  year)

Given a calendar year, return the GMT epoch seconds for midnight GMT of January 1 of that year. yearToSeconds(1970) == 0.

Definition at line 78 of file tz2icu.cpp.

References s, secsPerYear(), y, and year.

Referenced by ZoneInfo::mergeFinalData().

Variable Documentation

◆ finalRules

map<string,FinalRule> finalRules

Definition at line 902 of file tz2icu.cpp.

Referenced by main(), mapsToUnknownRule(), and readFinalZonesAndRules().

◆ finalZones

map<string,FinalZone> finalZones

Definition at line 901 of file tz2icu.cpp.

Referenced by main(), and readFinalZonesAndRules().

◆ HIGHEST_TIME32

const int64_t HIGHEST_TIME32 = (int64_t)((int32_t)0x7fffffff)

Definition at line 64 of file tz2icu.cpp.

Referenced by ZoneInfo::mergeFinalData(), ZoneInfo::print(), and readzoneinfo().

◆ HOUR

const int32_t HOUR = 3600

Definition at line 730 of file tz2icu.cpp.

Referenced by FinalZone::FinalZone(), and FinalRulePart::set().

◆ ICU44PLUS

◆ links

◆ LOWEST_TIME32

const int64_t LOWEST_TIME32 = (int64_t)((int32_t)0x80000000)

Definition at line 63 of file tz2icu.cpp.

Referenced by ZoneInfo::print(), and readzoneinfo().

◆ MONTH_LEN

const int32_t MONTH_LEN[] = {31,29,31,30,31,30,31,31,30,31,30,31}

Definition at line 728 of file tz2icu.cpp.

Referenced by FinalRulePart::set().

◆ reverseLinks

map<string, string> reverseLinks

Definition at line 905 of file tz2icu.cpp.

Referenced by main(), and readFinalZonesAndRules().

◆ ruleIDset

set<string> ruleIDset

This set is used to make sure each rule in finalRules is used at least once. First we populate it with all the rules from finalRules; then we remove all the rules referred to in finaleZones.

Definition at line 929 of file tz2icu.cpp.

Referenced by eraseRuleID(), insertRuleID(), and readFinalZonesAndRules().

◆ SECS_PER_LEAP_YEAR

const int64_t SECS_PER_LEAP_YEAR = 31622400

Definition at line 62 of file tz2icu.cpp.

Referenced by secsPerYear().

◆ SECS_PER_YEAR

const int64_t SECS_PER_YEAR = 31536000

Definition at line 61 of file tz2icu.cpp.

Referenced by secsPerYear().

◆ TIME_MODE

const char* TIME_MODE[] = {"w", "s", "u"}

Definition at line 724 of file tz2icu.cpp.

◆ TZ_RESOURCE_NAME

string TZ_RESOURCE_NAME = "zoneinfo64"

Definition at line 55 of file tz2icu.cpp.

Referenced by main().

◆ ZONEINFO

ZoneMap ZONEINFO

Definition at line 234 of file tz2icu.cpp.

Referenced by handleFile(), main(), and mergeOne().