time_zone~mamantoha

A helper to work with time zones in Crystal
0.1.1 Latest release released

TimeZone

Crystal CI GitHub release License

The TimeZone class serves as a helper to work with time zones in Crystal.

It allows to do the following:

  • Limit the set of zones to a meaningful subset of 151 zones.
  • Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      time_zone:
        github: mamantoha/time_zone
    
  2. Run shards install

Usage

require "time_zone"

zone = TimeZone.new("Taipei")
zone # => #<TimeZone:0x102b64f00 @name="Taipei", @location=#<Time::Location Asia/Taipei>, @utc_offset=28800>
puts zone
# (GMT+08:00) Taipei

zone.local # returns the current time in time zone "Asia/Taipei"

Contributing

  1. Fork it (https://github.com/mamantoha/time_zone/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

time_zone:
  github: mamantoha/time_zone
  version: ~> 0.1.1
License MIT
Crystal >= 1.0.0

Authors

Dependencies 0

Development Dependencies 1

  • ameba
    {'github' => 'crystal-ameba/ameba'}

Dependents 1

Last synced .
search fire star recently