{"id":17925058,"url":"https://github.com/zerowidth/jetlag","last_synced_at":"2025-06-30T07:33:41.588Z","repository":{"id":66410105,"uuid":"1605951","full_name":"zerowidth/jetlag","owner":"zerowidth","description":"AR timezone fixes for 2.3.x","archived":false,"fork":false,"pushed_at":"2012-06-06T15:33:40.000Z","size":120,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T09:32:39.007Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zerowidth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-12T19:57:47.000Z","updated_at":"2013-10-16T03:51:06.000Z","dependencies_parsed_at":"2023-02-20T03:45:38.562Z","dependency_job_id":null,"html_url":"https://github.com/zerowidth/jetlag","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zerowidth/jetlag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerowidth%2Fjetlag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerowidth%2Fjetlag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerowidth%2Fjetlag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerowidth%2Fjetlag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerowidth","download_url":"https://codeload.github.com/zerowidth/jetlag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerowidth%2Fjetlag/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262731757,"owners_count":23355417,"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":[],"created_at":"2024-10-28T20:52:06.829Z","updated_at":"2025-06-30T07:33:41.565Z","avatar_url":"https://github.com/zerowidth.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jetlag\n\nPatches for ActiveRecord 2.3.x timezone-handling code to allow for non-UTC\ndatabases.\n\nRails 3 mostly works, see discussion below.\n\n## Synopsis\n\nThis rails plugin patches ActiveRecord to fix the time quoting when timezones\nare involved, especially when using a non-UTC database.\n\nThis started as a set of specs to explore the various combinations of\nActiveRecord and related time zone settings and their effect on timestamp values\nas written and retrieved from a non-timezone-aware database.\n\nThe underlying motivation was to figure out the edge cases that exist when a\ndatabase is not running in UTC, and find where the ActiveRecord code fails to\nhandle this correctly. Eventually it ended up becoming a patch to correct the\ninvalid behavior.\n\n## Rails 3\n\nRails 3 timezone handling is correct, especially with the default settings. If\nyour database is not in UTC, make sure `ENV[\"TZ\"]` for your rails app is set\nappropriately, and set `ActiveRecord::Base.default_timezone = :local`. For more\ndetails, see the rails3 branch -- there are specs there showing that the\nbehavior is correct, even when changing Time.zone \"per request\".\n\n## Discussion\n\nThe rails convention is to keep all data in UTC. If, however, due to legacy\nreasons, your database is *not* UTC, Rails is unable to write (and thus read)\ndates with the correct timezone. This can lead to subtle bugs and, essentially,\ncorrupted data.\n\nActiveRecord does the incorrect thing in the following cases (copied from spec\noutput):\n\n    with Time.zone_default set (i.e. config.time_zone=) and default_timezone = :local and time_zone_aware_attributes = true (default)\n    - writes local Time objects to the database in UTC (invalid storage)\n    - writes local UTC Time objects as UTC (invalid storage)\n    - writes TimeWithZone objects using UTC (invalid storage)\n    - reads the timestamp as local but with the UTC offset (invalid round-trip)\n\n    with Time.zone_default set (i.e. config.time_zone=) and default_timezone = :local and time_zone_aware_attributes = false\n    - writes bare UTC timestamps as UTC (invalid storage)\n    - writes TimeWithZone objects as UTC (invalid storage)\n\n    with Time.zone_default set (i.e. config.time_zone=) and AR::Base.default_timezone = :utc (default) and time_zone_aware_attributes = false\n    - does not write bare timestamps as UTC (invalid storage)\n    - reads the timestamp as UTC (invalid round trip)\n\n    with Time.zone_default not set (i.e. config.time_zone is nil) with default_timezone as :local (default)\n    - writes bare UTC timestamps as UTC (invalid storage)\n\n    with Time.zone_default not set (i.e. config.time_zone is nil) with default_timezone as :utc\n    - does not write local timestamps as UTC (invalid storage)\n\nJetlag patches AR's column quoting to handle timezones correctly.\n\n## Installation\n\nTo use in your Rails 2.3.x application (as a plugin):\n\n    script/plugin install https://github.com/aniero/jetlag.git\n\nIf your database is not in UTC, set `ENV[\"TZ\"]` explicitly in your\n`config/environment.rb` to match the database's timezone, and also add the\nfollowing line after `config.time_zone = 'UTC'`:\n\n    config.active_record.default_timezone = :local\n\nTo run manually, e.g. non-rails use of ActiveRecord:\n\n    require \"jetlag\"\n    Jetlag.enable\n\nTo run the specs:\n\n    bundle\n    rake\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerowidth%2Fjetlag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerowidth%2Fjetlag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerowidth%2Fjetlag/lists"}