{"id":13879892,"url":"https://github.com/molybdenum-99/tz_offset","last_synced_at":"2025-10-19T07:24:11.274Z","repository":{"id":59158435,"uuid":"71931528","full_name":"molybdenum-99/tz_offset","owner":"molybdenum-99","description":"Simple abstraction of a timezone offset","archived":false,"fork":false,"pushed_at":"2023-01-22T01:17:45.000Z","size":30,"stargazers_count":38,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T07:50:42.423Z","etag":null,"topics":["dst","timezone"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/molybdenum-99.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-25T19:26:56.000Z","updated_at":"2022-05-18T14:31:30.000Z","dependencies_parsed_at":"2023-02-12T13:48:04.427Z","dependency_job_id":null,"html_url":"https://github.com/molybdenum-99/tz_offset","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molybdenum-99%2Ftz_offset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molybdenum-99%2Ftz_offset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molybdenum-99%2Ftz_offset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molybdenum-99%2Ftz_offset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/molybdenum-99","download_url":"https://codeload.github.com/molybdenum-99/tz_offset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225458198,"owners_count":17477408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dst","timezone"],"created_at":"2024-08-06T08:02:38.040Z","updated_at":"2025-10-19T07:24:11.223Z","avatar_url":"https://github.com/molybdenum-99.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# TZOffset\n\n[![Gem Version](https://badge.fury.io/rb/tz_offset.svg)](http://badge.fury.io/rb/tz_offset)\n[![Dependency Status](https://gemnasium.com/molybdenum-99/tz_offset.svg)](https://gemnasium.com/molybdenum-99/tz_offset)\n[![Build Status](https://travis-ci.org/molybdenum-99/tz_offset.svg?branch=master)](https://travis-ci.org/molybdenum-99/tz_offset)\n\nEver tried to convert your distant friend's or colleague's phrase \"OK, let's connect tomorrow\nat 6 pm my time (GMT+8)\" into easily calculatable Ruby code? E.g. what time it would be in your\ntimezone at 18:00 GMT+8? What is your favorite solution? Now it should be that:\n\n```ruby\nTZOffset.parse('GMT+8').local(2016, 10, 20, 18).localtime\n# =\u003e 2016-10-20 13:00:00 +0300\n\n# or just\nTZOffset.parse('+8').local(2016, 10, 20, 18).localtime\n# =\u003e 2016-10-20 13:00:00 +0300\n\n# Also works with most common timezone abbreviations\nTZOffset.parse('CEST').local(2016, 10, 20, 18).localtime\n# =\u003e 2016-10-20 19:00:00 +0300\n```\n\nIn other words, `TZOffset` is simple, no-magic, incapsulated abstraction of \"time offset\".\n\n## Features and problems\n\n* Easy-to-use, intuitive, dead simple, OS independent;\n* No brains included: no huge and comprehensive database of historical times, no automatic\n  DST conversion; you just know offset you need, and have it as a near-to-mathematical\n  value;\n* Simple value objects, easily converted to/from YAML (so you can save them to databases,\n  pass to delayed jobs and so on);\n* Knows about all common timezone abbreviations (got them from\n  [Wikipedia list](https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations));\n* For ambiguous abbreviations, just returns list of all of them:\n\n```ruby\nTZOffset.parse('EET')\n# =\u003e #\u003cTZOffset +02:00 (EET)\u003e\nTZOffset.parse('CDT')\n# =\u003e [#\u003cTZOffset -05:00 (CDT)\u003e, #\u003cTZOffset -04:00 (CDT)\u003e]\n```\n\n* For symbolic timezones, provides a description, if available:\n\n```ruby\nTZOffset.parse('CDT').map(\u0026:description)\n# =\u003e [\"Central Daylight Time (North America)\", \"Cuba Daylight Time\"]\nTZOffset.parse('CDT').map(\u0026:region)\n# =\u003e [\"Central\", \"Cuba\"]\n\n# NB: Just \"Central\", \"Eastern\" and so on is related to North America in timezones nomenclature\n```\n\n* for [DST](https://en.wikipedia.org/wiki/Daylight_saving_time) and non-DST timezones provides\n  dst-flag and counterpart timezone, if available:\n\n```ruby\neet = TZOffset.parse('EET')\n# =\u003e #\u003cTZOffset +02:00 (EET)\u003e\neet.dst?\n# =\u003e false\neet.opposite\n# =\u003e #\u003cTZOffset +03:00 (EEST)\u003e\n[eet.description, eet.opposite.description]\n# =\u003e [\"Eastern European Time\", \"Eastern European Summer Time\"]\n```\n\n## Installation\n\nDo your usual routine with gem named `tz_offset` (e.g. `gem install tz_offset` or add\n`gem \"tz_offset` to your `Gemfile`).\n\n## Usage\n\nMost of it is already shown above!\n\n```ruby\nrequire 'tz_offset'\n\noff = TZOffset.parse('-02:30')\n# =\u003e #\u003cTZOffset -02:30\u003e\noff.now\n# =\u003e 2016-10-25 16:07:55 -0230\noff.local(2016, 10, 1)\n# =\u003e 2016-10-01 00:00:00 -0230\n\neet = TZOffset.parse('EET')\n# =\u003e #\u003cTZOffset +02:00 (EET)\u003e\neet.now\n# =\u003e 2016-10-25 20:29:03 +0200\neet.description\n# =\u003e \"Eastern European Time\"\neet.region\n# =\u003e \"Eastern European\"\neet.opposite\n# =\u003e #\u003cTZOffset +03:00 (EEST)\u003e\neet.opposite.now\n# =\u003e 2016-10-25 21:39:26 +0300\n\n# Parsing time string into desired timezone\noff = TZOffset.parse('-02:30')\noff.parse('2014-10-01 12:30')\n# =\u003e 2014-10-01 12:30:00 -0230\noff.parse('12:30')\n# =\u003e 2016-10-26 12:30:00 -0230\n```\n\n## Author\n\n[Victor Shepelev](http://zverok.github.io/) -- extracted from [reality](https://github.com/molybdenum-99/reality)\nproject.\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolybdenum-99%2Ftz_offset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmolybdenum-99%2Ftz_offset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolybdenum-99%2Ftz_offset/lists"}