{"id":13877937,"url":"https://github.com/floraison/et-orbi","last_synced_at":"2025-05-16T16:01:30.797Z","repository":{"id":44638136,"uuid":"85383339","full_name":"floraison/et-orbi","owner":"floraison","description":"Time zones for fugit and rufus-scheduler. Urbi et Orbi.","archived":false,"fork":false,"pushed_at":"2025-04-16T11:05:48.000Z","size":373,"stargazers_count":25,"open_issues_count":1,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-11T12:35:55.898Z","etag":null,"topics":["ruby","time","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floraison.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-18T07:21:55.000Z","updated_at":"2025-04-16T11:05:52.000Z","dependencies_parsed_at":"2023-01-30T23:01:22.597Z","dependency_job_id":"a90c54ee-6e0a-40c4-88a1-da335864987c","html_url":"https://github.com/floraison/et-orbi","commit_stats":{"total_commits":469,"total_committers":9,"mean_commits":"52.111111111111114","dds":"0.023454157782516027","last_synced_commit":"7689226107013f4f4455895f9eb1df149528186d"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fet-orbi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fet-orbi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fet-orbi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fet-orbi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floraison","download_url":"https://codeload.github.com/floraison/et-orbi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553936,"owners_count":22090415,"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":["ruby","time","timezone"],"created_at":"2024-08-06T08:01:35.364Z","updated_at":"2025-05-16T16:01:30.691Z","avatar_url":"https://github.com/floraison.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"\n# et-orbi\n\n[![tests](https://github.com/floraison/et-orbi/workflows/test/badge.svg)](https://github.com/floraison/et-orbi/actions)\n[![Gem Version](https://badge.fury.io/rb/et-orbi.svg)](http://badge.fury.io/rb/et-orbi)\n\nTime zones for [fugit](https://github.com/floraison/fugit) and for [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler). Urbi et Orbi.\n\n`EtOrbi::EoTime` instances quack like Ruby `Time` instances, but their `#zone` returns a `TZInfo::TimeZone` instance.\n\nGetting `EoTime` instances:\n```ruby\nrequire 'et-orbi'\n\nEtOrbi.now\n  # =\u003e #\u003cEtOrbi::EoTime:0x007f94d94 ...\u003e\nEtOrbi.now('Asia/Singapore')\n  # =\u003e #\u003cEtOrbi::EoTime:0x39c96e48 @time=nil, @zone=#\u003cTZInfo::DataTimezone: Asia/Singapore\u003e...\u003e\nEtOrbi.parse('2017-12-13 13:00:00 America/Jamaica')\n  # =\u003e #\u003cEtOrbi::EoTime:0x007f94d90 @zone=#\u003cTZInfo::DataTimezone: America/Jamaica\u003e...\u003e\nEtOrbi.make_time(Time.now)\n  # =\u003e #\u003cEtOrbi::EoTime:0x007f94d91 ...\u003e\n\nEtOrbi.make_time(2017, 1, 31, 12, 'Europe/Moscow').to_debug_s\n  # =\u003e 'ot 2017-01-31 12:00:00 +03:00 dst:false'\n\nEtOrbi::EoTime.new(0, 'UTC').to_s\n  # =\u003e \"1970-01-01 00:00:00 +0000\"\nEtOrbi::EoTime.new(0, 'Europe/Moscow').to_s\n  # =\u003e \"1970-01-01 03:00:00 +0300\"\nEtOrbi::EoTime.new(0, 'Europe/Moscow').to_zs\n  # =\u003e \"1970-01-01 03:00:00 Europe/Moscow\" # \"be precise in your speech\"\n\nEtOrbi.parse('1970-01-01 03:00:00 Europe/Moscow')\n  # =\u003e #\u003cEtOrbi::EoTime:0x00007fa4bc83fcd0\n  #  @seconds=0.0, @zone=#\u003cTZInfo::DataTimezone: Europe/Moscow\u003e, @time=nil\u003e\n```\n\nMore about `EtOrbi::EoTime` instances:\n```ruby\neot = EtOrbi::EoTime.new(0, 'Europe/Moscow')\n\neot.to_local_time.class  # =\u003e Time\neot.to_local_time.to_s   # =\u003e \"1970-01-01 09:00:00 +0900\" (at least on my system)\n\n# For the rest, EtOrbi::EoTime mimics ::Time\n```\n\nHelper methods:\n```ruby\nrequire 'et-orbi'\n\nEtOrbi.get_tzone('Europe/Vilnius')\n  # =\u003e #\u003cTZInfo::DataTimezone: Europe/Vilnius\u003e\nEtOrbi.local_tzone\n  # =\u003e #\u003cTZInfo::TimezoneProxy: Asia/Tokyo\u003e\n\nEtOrbi.platform_info\n  # =\u003e \"(etz:nil,tnz:\\\"JST\\\",tzid:nil,rv:\\\"2.2.6\\\",rp:\\\"x86_64-darwin14\\\",eov:\\\"1.0.1\\\",\n  #      rorv:nil,astz:nil,debian:nil,centos:nil,osx:\\\"Asia/Tokyo\\\")\"\n    #\n    # etz: ENV['TZ']\n    # tnz: Time.now.zone\n    # tzid: defined?(TZInfo::Data)\n    # rv: RUBY_VERSION\n    # rp: RUBY_PLATFORM\n    # eov: EtOrbi::VERSION\n    # rorv: Rails::VERSION::STRING\n    # astz: ActiveSupport provided Time.zone\n```\n\n### Chronic integration\n\nBy default, et-orbi relies on [Chronic](https://github.com/mojombo/chronic) to parse strings like \"tomorrow\" or \"friday 1pm\", if `Chronic` is present.\n\n```ruby\nEtOrbi.parse('tomorrow')\n  # =\u003e #\u003cEtOrbi::EoTime:0x007fbc6aa8a560\n  #      @seconds=1575687600.0,\n  #      @zone=#\u003cTZInfo::TimezoneProxy: Asia/Tokyo\u003e,\n  #      @time=nil\u003e\nEtOrbi.parse('tomorrow').to_s\n  # =\u003e \"2019-12-07 12:00:00 +0900\"\n```\n\nThis is a poor design choice I replicated from [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler).\n\nOf course this leads to [issues](https://gitlab.com/gitlab-org/gitlab/issues/37014).\n\nIt's probably better to have Chronic do its work outside of et-orbi, like in:\n```ruby\nEtOrbi.parse(Chronic.parse('tomorrow').to_s).to_s\n  # =\u003e \"2019-12-07 12:00:00 +0900\"\n```\n\nIf one has Chronic present in their project but doesn't want it to interfere with et-orbi, it can be disabled at `parse` call:\n```ruby\nEtOrbi.parse('tomorrow')\n  # =\u003e #\u003cEtOrbi::EoTime:0x007ffb5b2a2390\n  #      @seconds=1575687600.0,\n  #      @zone=#\u003cTZInfo::TimezoneProxy: Asia/Tokyo\u003e,\n  #      @time=nil\u003e\nEtOrbi.parse('tomorrow', enable_chronic: false)\n  # ArgumentError: No time information in \"tomorrow\"\n  #   from /home/jmettraux/w/et-orbi/lib/et-orbi/make.rb:31:in `rescue in parse'\n```\nor at the et-orbi level:\n```ruby\nirb(main):007:0\u003e EtOrbi.chronic_enabled = false\n  # =\u003e false\nirb(main):008:0\u003e EtOrbi.chronic_enabled?\n  # =\u003e false\nEtOrbi.parse('tomorrow')\n  # ArgumentError: No time information in \"tomorrow\"\n  #   from /home/jmettraux/w/et-orbi/lib/et-orbi/make.rb:31:in `rescue in parse'\n```\n\n### Rails?\n\nIf Rails is present, `Time.zone` is provided and EtOrbi will use it, unless `ENV['TZ']` is set to a valid timezone name. Setting `ENV['TZ']` to nil can give back precedence to `Time.zone`.\n\nRails sets its timezone under `config/application.rb`.\n\n\n## Related projects\n\n### Sister projects\n\n* [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) - a cron/at/in/every/interval in-process scheduler, in fact, it's the father project to this fugit project\n* [fugit](https://github.com/floraison/fugit) - Time tools for flor and the floraison project. Cron parsing and occurrence computing. Timestamps and more.\n\n\n## LICENSE\n\nMIT, see [LICENSE.txt](LICENSE.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloraison%2Fet-orbi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloraison%2Fet-orbi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloraison%2Fet-orbi/lists"}