Giter VIP home page Giter VIP logo

timezone-olson's Introduction

timezone-olson

On Hackage: timezone-olson

This package provides a parser and renderer for binary Olson timezone files whose format is specified in RFC 8536.

Functions are provided for converting the parsed data into TimeZoneSeries objects from the timezone-series package. On many platforms, binary Olson timezone files suitable for use with this package are available in the directory /usr/share/zoneinfo and its subdirectories on your computer.

See also the timezone-olson-th package for a way to include timezone informaton from a binary Olson timezone file at compile time.

Copyright (c) 2010-2021 Yitzchak Gale. All rights reserved.

For licensing information, see the BSD3-style license in the file LICENSE that was originally distributed by the author together with this file.

This package is part of the time-ng project.

Testing utilities

This package also provides two Haskell files, each of which can be compiled into a command-line utility that might be helpful for testing purposes.

zhdump.hs: A clone of zdump(8), including most of its bugs, that is usually present on systems that have an Olson timezone database, except hzdump takes paths to timezone files instead of timezone identifiers on the command line.

catTZ: Read and parse a timezone file, then render it. With the -i flag, interprets the timezone data as a TimeZoneSeries object before rendering.

timezone-olson's People

Contributors

dependabot[bot] avatar k0001 avatar niteria avatar richsmith92 avatar ygale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

timezone-olson's Issues

Requesting revision of timezone-olson 0.1.9 with looser time bound

I see the repo has advanced to the 0.2 series. But there are still libraries such as timezone-olson-th that depend on the 0.1.* series. I noticed that the 0.1.9 release works just fine with time<1.14 instead of its current time<1.10 bound. I am having a problem compiling with time 1.9 on GHC 9.2, so I would appreciate if this bound could be loosened. Thank you.

Wall and UT indicators are not parsed correctly.

I have a TZif v2 file that looks like this:

00000000  54 5a 69 66 32 00 00 00  00 00 00 00 00 00 00 00  |TZif2...........|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 01 00 00 00 02  00 00 00 08 92 e6 92 48  |...............H|
00000030  01 ff ff fc 38 00 00 00  00 00 00 00 04 4c 4d 54  |....8........LMT|
00000040  00 47 4d 54 00 54 5a 69  66 32 00 00 00 00 00 00  |.GMT.TZif2......|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  01 00 00 00 02 00 00 00  |................|
00000070  08 ff ff ff ff 92 e6 92  48 01 ff ff fc 38 00 00  |........H....8..|
00000080  00 00 00 00 00 04 4c 4d  54 00 47 4d 54 00 0a 47  |......LMT.GMT..G|
00000090  4d 54 30 0a                                       |MT0.|

(/usr/share/zoneinfo/Africa/Abidjan from tzdata-2019b-1 on Arch Linux)

It's being parsed into the following OlsonData:

OlsonData {olsonTransitions = [Transition {transTime = -1830383032, transIndex = 1},Transition {transTime = -1830383032, transIndex = 1}], olsonTypes = [], olsonLeaps = [], olsonPosixTZ = Just "GMT0"}

Note that olsonTypes is empty while olsonTransitions references into it, this is obviously incorrect.

The source of the issue seems to be that the v1 header contains, in RFC8536 jargon, typecnt=2 but isutcnt=0 and isstdcnt=0. The RFC states:

standard/wall indicators: A series of one-octet values indicating
whether the transition times associated with local time types were
specified as standard time or wall-clock time. Each value MUST be
0 or 1. A value of one (1) indicates standard time. The value
MUST be set to one (1) if the corresponding UT/local indicator is
set to one (1). A value of zero (0) indicates wall time. The
number of values is specified by the "isstdcnt" field in the
header. If "isstdcnt" is zero (0), all transition times
associated with local time types are assumed to be specified as
wall time.

UT/local indicators: A series of one-octet values indicating whether
the transition times associated with local time types were
specified as UT or local time. Each value MUST be 0 or 1. A
value of one (1) indicates UT, and the corresponding standard/wall
indicator MUST also be set to one (1). A value of zero (0)
indicates local time. The number of values is specified by the
"isutcnt" field in the header. If "isutcnt" is zero (0), all
transition times associated with local time types are assumed to
be specified as local time.

Emphasized part is suggesting that the file above is valid, and should be interpreted as if all transitions happened in Wall time.

The related logic is implemented in https://github.com/ygale/timezone-olson/blob/master/Data/Time/LocalTime/TimeZone/Olson/Parse.hs#L152-L165 where zipWithExtend is used in case either the isstds or the isgmts is shorter than the other. However then regular zipWith is used to join the resulting list with the list of ttinfos.

Thus the case when both isstds and isgmts are shorter than ttinfos is not handled and we get a truncated list of types as above.

Please update Hackage

Various zone files (eg Etc/UTC) aren't handled on my system because they're using RFC 8536 and need 4ff152b. Would you be able to upload a new version to Hackage, please?

Time-zone conversions after 2037 wrong

I ran this test program:

module Main where
import Data.Time
import Data.Time.LocalTime.TimeZone.Series
import Data.Time.LocalTime.TimeZone.Olson

main :: IO ()
main = do
    tzs <- getTimeZoneSeriesFromOlsonFile "/usr/share/zoneinfo/America/New_York"
    putStrLn $ show $ timeZoneFromSeries tzs $ UTCTime (fromGregorian 2038 7 1) 0

Result:

EST

By comparison, the C library correctly gives EDT:

$ env TZ=America/New_York date -d '2038-07-01 UTC'
Wed Jun 30 20:00:00 EDT 2038

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.