time zone handling
When using NTP to set the current time, it is always set to UTC. The mbed libraries have no notion of timezone handling. This library can read time zone definitions, and can calculate the proper local time. It also handles the daylight savings.
- first, set up the time zone file as described below
- make sure you have mounted the time zone file under /local
- in your code, set the current time (preferably via an NTP call)
- create a /Time/ object
- whenever you need the current local time, create a TimeStamp object via the Time object
- use the provided methods to get the time
A demo program can be found here (Note: is uses an NTP server suited for Germany, so you might want to change this).
This library uses time zones files in CSV format, as provided by this project.
- go to the project page
- download the most current data file (right now this is tzdata_2010o.zip)
- extract it
- go to the tzdata/csv folder
- look for the csv file matching your location the best (use one of the global time zones, or by city divided by continents)
- copy this file as 'timezone.csv' to the mbed USB disk
After that, use the library as described.
8 comments on time zone handling:
Please login to post comments.