From ae94beef3ab7ce25f7396e352e73b15de3b7cd9e Mon Sep 17 00:00:00 2001 From: konrad Date: Fri, 9 Jul 2010 11:31:34 +0000 Subject: [PATCH] correct and extend README add LGPL git-svn-id: https://silmor.de/svn/softmagic/tzone/trunk@549 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- COPYING | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++ README | 178 +++++++++++++++++++++++++++++++++++++------------------ genemptyrcc.sh | 22 +++++++ tzreg.h | 2 +- tzsys.h | 1 + tzsys_win.cpp | 4 + 6 files changed, 313 insertions(+), 59 deletions(-) create mode 100644 COPYING create mode 100755 genemptyrcc.sh diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..fc8a5de --- /dev/null +++ b/COPYING @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README b/README index 7816461..3aa106f 100644 --- a/README +++ b/README @@ -1,10 +1,13 @@ Qt TimeZone Interface - README ======================================== -This is a wrapper library around the Olsen Time Zone Database. +This is a wrapper library for Qt around the Olsen Time Zone Database. The library can read TZ DBs compiled time zone DB files. It transforms unix timestamps, its own format and QDateTime objects. +Other than the original tzcode package it can be compiled out of the +box with Qt for Windows. + Copyright ---------- @@ -22,57 +25,9 @@ ftp://elsie.nci.nih.gov/pub/ Big Fat Warning ------------------ -So far this software is beta. This means it might corrupt your data, eat your -disk, Magic Smoke Ticket Sale System - README -======================================== - -Magic Smoke was written to keep track of tickets for events (like concerts -or theatric plays), sell them online or through retailers. It does not keep -your books or handle any financial transactions (except for the ability to -track whether tickets are paid). - -This is NOT a system for support tickets. - -Mind the warning below. - -See the HTML files in the doc directory for more information. - -Copyrights ------------ - -(c) Konrad Rosenbaum, 2007-2010 -(c) Peter Keller, 2007/8 - -Directory doc: -Documentation (directory doc) is currently licensed under FDLv1.2 without -invariant sections, but will be relicensed when SFDL is released by the FSF. -See COPYING.FDL for details. (COPYING.SFDL contains the current draft of SFDL -as a preview, but is currently not binding.) - -Directories src, mkdist: -The CPP-source files are licensed under GPLv3 or at your option any newer version -of the license. See COPYING.GPL for details. - -Directories zip, pack, tzone: -See the README files in there for details. - -Directory www, wob: -The web-code (PHP files) and object meta files (*.wolf) are licensed under -GNU AGPLv3 (see COPYING.AGPL for details). This excludes the www/template -sub-directory. - -Directories www/template and examples: -Templates for web-pages (www/template) and examples for ODF and ticket templates -(examples) are in the public domain. -Which means eg. they can be freely modified and then put under any license when -you create your own web-site using this software. - - -Big Fat Warning ------------------- - -So far this software is beta. This means it might corrupt your data, eat your -disk, misplace next weeks appointments, etc. ad infinitum, ad nauseam, ... +So far this software is beta. This means it might calculate the wrong time, +corrupt your data, eat your disk, misplace next weeks appointments, etc. +ad infinitum, ad nauseam, ... This software comes with no warranty at all. You use it at your own risk. @@ -84,14 +39,121 @@ simply call: qmake make -Documentation can be built with calling: doxygen +Source Documentation: +1) can be built with calling doxygen +2) you'll find the documentation in sourcedoc On Unix systems (or Cygwin) with installed timezone tools (the tzcode package) you are free to change the built in TZ database. -If you want to build the library without the built in database comment out -the zonefiles.cpp line in tzdata.pro or empty the cpp file. +If you want to build the library without the built in database: +1) call genemptyrcc.sh +2) call make to rebuild the library + +If you want to rebuild the built in database: +1) drop new zone description files (tzdata*.tar.gz) in the db subdirectory, if + some of the new files were not present previously you may need to tweek the + Makefile in db +2) simply call genrcc.sh - it will go into the db directory and rebuild the + database files, then it will include them into the zonefiles.qrc/cpp files. +3) Then call make to rebuild the library. + + +Using it +---------- + +Simply some lines like these to your project file: +TZLIB = Path/To/TZLib +LIBS += -L$TZLIB -ltzdata +INCLUDEPATH += $TZLIB + +Then #include in your source code and use the TimeStamp class. +It has been made as compatible as possible with the Qt classes, but there +are some differences in behavior. +See the source docu for details about this class. + +Upon the first use of any interface in the TimeStamp class the library +initializes itself. This includes detection of the currently active time +zone. + +The other classes in this package are not meant for direct use unless you +want to access the time zone database directly. The database interface can +be found in - please be aware that although TimeStamp uses that +interface you cannot use it directly to change the behavior of TimeStamp, +since TimeStamp uses its own internal cache of time zones. + +Time zone detection: +On Linux/Unix systems the library inspects the TZ environment variable and +a few files that usually contain the name of the time zone. It expects to +find an Olson name like "Europe/Berlin". +On Windows it looks into the Windows registry to find the Windows name of +the time zone, it then compares this with a list of mappings and returns the +corresponding Olson name. +Per default on other systems the library tries to use the Linux way. +If the library cannot interpret what it gets from the system or does not +know how to load that time zone it will revert to UTC - which is probably not +what you wanted. +Even if a match is found the loaded time zone of the library may vary in some +subtle details from what the system uses for various reasons: +* Windows has a much simple system of time zones than the Olson DB does, + for example it cannot handle anything but 0 and 2 changes of offset from + UTC per year. +* Linux and other Olson DB based systems may have a different version of the + database installed (although it is unlikely if you remain at the defaults), + for example there is a version with and without leap seconds (default is without) + and some countries tend to change rules sporadically +* older POSIX compliant systems also use a very simple description format + that can only handle no or two changes of offset + +If time zone detection fails for you, you can always use TimeStamp::setDefaultZone +and TimeStamp::storeDefaultZone to fix it to something more closely resembling +your system. + +Hacking it +------------ + +A lot of the internal interfaces are exposed, so that they can be tested. That does not +mean they are meant for normal use of the library. All interfaces marked as "internal" in +the source documentation may change radically or even disappear in subsequent releases. + +List of Files: +----- + +tzdata.* - the normal interface providing a TimeStamp class that should suffice for most uses + +tzfile.* - the code for accessing time zone files + +tzreg.h - strictly internal: it exposes the internal zone registry for testing + +tzhelp.h - inline helper functions for calculations, they are not meant for direct use, even + if you decide to access files directly, use them through TZRule instead, + if you change them you most probably break something! + +tzsys* - helper functions to detect the local time zone, so far a version for Linux and + Windows exist. You may need to extend this if you port the library to more traditional + Unix systems that do not have the Olson DB installed, I'm unsure whether the Linux logic + works on MacOS/X. + + +List of Classes +----- + +TimeStamp - the main user interface + +TZFile, TZRule, PosixRule - the interface into TZ database files, they can be used to inspect + those files + + +List of sub-directories: +----- + +Test Cases are found in the test directory, please use them if you change the library +code - it is very easy to break the calculations. First build the library, then enter +the test directory and build the test cases, you can execute them by calling ./tztest . + +The pscan utility is a small helper for finding POSIX fallback rules - I use it to find +all the rules present in the database. Please read the Theory file of the original DB +distribution to understand those rules. You need to worry if you ever find a rule that +applies a shift to/from DST on January 1st or December 31st - in that case some heuristics +in my code may fail. -If you want to rebuild the built in database simply call genrcc.sh - it -will go into the db directory and rebuild the database files, then it will include -them into the zonefiles.qrc/cpp files. Then call make to rebuild the library. diff --git a/genemptyrcc.sh b/genemptyrcc.sh new file mode 100755 index 0000000..7f888b4 --- /dev/null +++ b/genemptyrcc.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo removing old zone info +rm -rf zoneinfo* + +echo "empty zone" >zoneinfo + +ZF=zonefiles.qrc + +cat <$ZF + + + + zoneinfo + + +EOF + +echo generating source... +rcc $ZF -name ${ZF%.qrc} -o ${ZF%.qrc}.cpp + +echo Done. diff --git a/tzreg.h b/tzreg.h index 1ac1a04..d523a10 100644 --- a/tzreg.h +++ b/tzreg.h @@ -18,7 +18,7 @@ namespace TimeZoneLib { class TZFile; -/** \internal registry access */ +/** \internal registry access for unit testing only!! */ TZFile& getRegistryZone(QString zn); }; diff --git a/tzsys.h b/tzsys.h index 4d3f279..72d82a2 100644 --- a/tzsys.h +++ b/tzsys.h @@ -16,6 +16,7 @@ #include namespace TimeZoneLib { + /** \internal detect the default time zone of the system, the implementation differs between systems*/ QString systemDefaultDiscover(); } diff --git a/tzsys_win.cpp b/tzsys_win.cpp index c4ef1b3..3c3cb27 100644 --- a/tzsys_win.cpp +++ b/tzsys_win.cpp @@ -20,6 +20,8 @@ using namespace TimeZoneLib; +// internal: accesses the registry to find the windows name of the currently set time zone +// helper to systemDefaultDiscover static QString systemDefaultDiscover_win() { //assign myself to the registry @@ -214,6 +216,8 @@ Western Brazilian Standard Time|America/Rio_Branco\n\ Yakutsk|Asia/Yakutsk\n\ Yakutsk Standard Time|Asia/Yakutsk"; +//windows implementation of system default time zone discovery +// takes a windows time zone name (see above) and maps it to an Olson DB name QString TimeZoneLib::systemDefaultDiscover() { QString win=systemDefaultDiscover_win().trimmed(); -- 1.7.2.5