0

In the past I implemented C# library which, given local DateTime and lat/lon, allowed to determine a timezone and offset.

I did the following:

  • downloaded shapefiles from efele.net/maps/tz
  • imported them into SQL Server
  • used them to get tzid from lat/lon

Noda Time C# library was used to get all necessary information about timezone, offset, and DST. It returns:

  • Offset in minutes
  • UTC DateTime
  • Olson/IANA Timezone name
  • Windows Timezone name
  • bool IsDST

Now I need to reproduce this library in NodeJs + PostgreSQL. Is the suggested way of doing it:

  • Import http://efele.net/maps/tz shapefiles to PostgreSQL
  • Use Moment TimeZone library in NodeJs similar to how I used Noda Time in C#

Are there known pitfalls, difficulties?

Dario
  • 3,905
  • 2
  • 13
  • 27
vkelman
  • 1,501
  • 1
  • 15
  • 25

1 Answers1

1

As you said, you need some actualized shapefile to map all timezones by geo coordinates.

You can use a module like geo-tz that natively support moment-timezone library. Or a more lightweight one like tz-lookup.

Community
  • 1
  • 1
Dario
  • 3,905
  • 2
  • 13
  • 27
  • Dario, In geo-tz .tzMoment(lat, lon, [dateTime]) dateTime parameter is a *local* dateTime, correct? Looks like geo-tz already implemented what I was going to implement! Wow! I couldn't find such ready to use C# library 3 years ago, so I implemented my own with a big help of @MattJohnson – vkelman Jul 29 '16 at 15:45
  • 1
    Yes, "(...) If dateTime is provided, `moment-timezone` will be set to the time provided according to the timezone found". – Dario Jul 29 '16 at 15:49