Giter Site home page Giter Site logo

timezoneinfo's Introduction

TimeZoneInfo

With the use of the tzdata your project can now run in local time. Getting UTC time is easy, (GPS, NTP, ..) but local time is not. GMT plus x works mostly only for half of a year. (Daylight-Saving-Time) DST is evil! You can't calculate it! This is why linux uses a database to make DST work. So, why not using it for your Arduino? It is a bit "heavy", prox. 4kB for the database of one location + the code to make it work.

This is a 32-Bit version! Year 2038 will come fast!

Example

UtcToLocal

TimeZoneInfo-Test

Berlin
UTC=00:59:57 27.03.2016
LOC=01:59:57 27.03.2016 CET

UTC=00:59:58 27.03.2016
LOC=01:59:58 27.03.2016 CET

UTC=00:59:59 27.03.2016
LOC=01:59:59 27.03.2016 CET

UTC=01:00:00 27.03.2016
LOC=03:00:00 27.03.2016 DST CEST

UTC=01:00:01 27.03.2016
LOC=03:00:01 27.03.2016 DST CEST

UTC=01:00:02 27.03.2016
LOC=03:00:02 27.03.2016 DST CEST


Los_Angeles
UTC=08:59:57 06.11.2016
LOC=01:59:57 06.11.2016 DST PDT

UTC=08:59:58 06.11.2016
LOC=01:59:58 06.11.2016 DST PDT

UTC=08:59:59 06.11.2016
LOC=01:59:59 06.11.2016 DST PDT

UTC=09:00:00 06.11.2016
LOC=01:00:00 06.11.2016 PST

UTC=09:00:01 06.11.2016
LOC=01:00:01 06.11.2016 PST

UTC=09:00:02 06.11.2016
LOC=01:00:02 06.11.2016 PST

Done.


Database

Getting the tzfile-database is easy in linux.

Usualy these files are in /usr/share/zoneinfo.

Converting to a C-header file:

  1. With the "build-in" xxd-tool

    cd /usr/share/zoneinfo/Europe
    # Add PROGMEM, if not your are running out of RAM.
    xxd -i Berlin | sed -e 's/unsigned char/unsigned char PROGMEM/' > ~/Arduino/MyProject/Berlin.h
    
  2. With my binhex-Tool

    ./binhex -f /usr/share/zoneinfo/America/Los_Angeles -p ZI_LA > ~/Arduino/MyProject/America_Los_Angeles.h
    

License

GPLv2

timezoneinfo's People

Contributors

rstephan avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.