Use time zones to derive local time instead of UTC offset.

  * move logic to the lib/ folder