<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im" -->

---
title: Adventures in Daylight Saving, Norfolk Island, and Time...
description: A deep dive into two real bug reports against the Ruby gem distance_of_time_in_words (dotiw), both stemming from time zone offset math. The first bug involved...
canonical: https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Adventures in Daylight Saving, Norfolk Island, and Time Zone Math (in Ruby) | daily.dev
og:description: A deep dive into two real bug reports against the Ruby gem distance_of_time_in_words (dotiw), both stemming from time zone offset math. The first bug involved...
og:url: https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im
og:image: https://api.daily.dev/og/posts/HlVuf76im.png
og:image:alt: Adventures in Daylight Saving, Norfolk Island, and Time Zone Math (in Ruby)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Adventures in Daylight Saving, Norfolk Island, and Time Zone Math (in Ruby)

**[RUBYLAND](https://daily.dev/sources/rubyla)** · 10 min read · 2 upvotes · 0 comments

## Summary

A deep dive into two real bug reports against the Ruby gem distance_of_time_in_words (dotiw), both stemming from time zone offset math. The first bug involved Europe/Dublin's inverted DST scheme causing dst? to report inconsistent values depending on how a Time object was constructed, leading to a real one-minute duration being reported as zero; the fix was to compare utc_offset directly instead of relying on dst?. The second bug involved Pacific/Norfolk's permanent one-time UTC offset change from +11:30 to +11:00 in 2015, which broke code that assumed all offset changes were ±1 hour DST transitions; the fix generalized the offset delta calculation. Both fixes shipped in dotiw 5.6.0. The author then tested the same two scenarios against similar humanize-duration libraries in JavaScript, Python, Go, Rust, PHP, C#, Java, and Elixir, finding that Elixir's Timex reproduces the Norfolk bug while most others avoid it structurally by not building compound calendar breakdowns; PHP's Carbon is the only one that supports a compound breakdown and still handles it correctly.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://code.dblock.org/2026/08/28/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby.html>

## Questions this post answers

### Why does Europe/Dublin cause dst? to give inconsistent results for the same instant in Ruby?

Europe/Dublin uses an inverted DST scheme where standard time is legally defined as summer time minus one hour rather than winter time being standard. Depending on whether a Time was constructed via Time.at(seconds) or datetime.to_time, dst? can report different values for the same instant even though utc_offset agrees, so code relying on dst? for offset corrections can misfire in Dublin specifically.

_Developers hardening time zone logic against edge cases like this can find real-world gotchas surfaced on daily.dev._

### Why did Pacific/Norfolk cause a duration calculation bug in the dotiw Ruby gem?

Norfolk Island permanently changed its UTC offset from +11:30 to +11:00 on 4 October 2015, a one-time tzdata rule change rather than a recurring seasonal DST transition. Code that hardcoded a ±1 hour DST correction had no way to represent this 30-minute permanent shift, causing a spurious 23 hours and 30 minutes to leak into what should have been a clean 1 year and 2 months calendar distance. The fix (PR #154) replaced the fixed hour assumption with a general offset_delta calculation.

_Anyone building duration or calendar-diff logic can track these tzdata-driven edge cases via daily.dev._

### Do other programming languages' time-humanizing libraries have the same DST and time zone offset bugs as Ruby's dotiw?

Testing date-fns, dayjs, moment.js, humanize, arrow, go-humanize, chrono-humanize, DateTime::diff, Carbon, Humanizer, PrettyTime, and Timex against the Dublin DST and Norfolk Island offset scenarios showed all were clean on Dublin, and all but Elixir's Timex were clean on Norfolk. Most avoid the bug structurally by rounding to a single largest unit rather than building a compound years/months/weeks/days/hours/minutes breakdown; PHP's Carbon is the exception that supports compound breakdowns yet still computes offsets correctly at the DateInterval level.

_Teams comparing date-time libraries across languages can weigh these tradeoffs using resources shared on daily.dev._

## Similar posts on daily.dev

- [The surprising whimsy of the Time Zone Database](https://daily.dev/posts/the-surprising-whimsy-of-the-time-zone-database-eybzj43kg) · Hacker News · 0 upvotes · 0 comments
- [It's About Time](https://daily.dev/posts/it-s-about-time-hly3n9l9f) · The Daily WTF · 0 upvotes · 0 comments
- [Before NTP there were Time and Daytime](https://daily.dev/posts/before-ntp-there-were-time-and-daytime-onwof2jqj) · Jeff Geerling · 2 upvotes · 1 comments
- [British Columbia, Time Zones, and Postgres](https://daily.dev/posts/british-columbia-time-zones-and-postgres-uiebxsyyj) · Crunchy Data · 0 upvotes · 0 comments
- [Stop using DateTime in 2026 \(unless you work for UNESCO\)](https://daily.dev/posts/stop-using-datetime-in-2026-unless-you-work-for-unesco--qwnlzpkwl) · arkency · 0 upvotes · 0 comments

---

Tags: [#open-source](https://daily.dev/tags/open-source), [#ruby](https://daily.dev/tags/ruby)

[View this post on daily.dev](https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Adventures in Daylight Saving, Norfolk Island, and Time Zone Math (in Ruby)","url":"https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im"},"datePublished":"2026-08-28T22:51:43.368Z","dateModified":"2026-10-14T02:32:20.450Z","description":"A deep dive into two real bug reports against the Ruby gem distance_of_time_in_words (dotiw), both stemming from time zone offset math. The first bug involved...","image":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","thumbnailUrl":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","isAccessibleForFree":true,"articleSection":"RUBYLAND","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"RUBYLAND","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/rubyla","url":"https://daily.dev/sources/rubyla"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"open-source,ruby","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"RUBYLAND","item":"https://daily.dev/sources/rubyla"},{"@type":"ListItem","position":3,"name":"Adventures in Daylight Saving, Norfolk Island, and Time Zone Math (in Ruby)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/adventures-in-daylight-saving-norfolk-island-and-time-zone-math-in-ruby--hlvuf76im#faq","mainEntity":[{"@type":"Question","name":"Why does Europe/Dublin cause dst? to give inconsistent results for the same instant in Ruby?","acceptedAnswer":{"@type":"Answer","text":"Europe/Dublin uses an inverted DST scheme where standard time is legally defined as summer time minus one hour rather than winter time being standard. Depending on whether a Time was constructed via Time.at(seconds) or datetime.to_time, dst? can report different values for the same instant even though utc_offset agrees, so code relying on dst? for offset corrections can misfire in Dublin specifically. Developers hardening time zone logic against edge cases like this can find real-world gotchas surfaced on daily.dev."}},{"@type":"Question","name":"Why did Pacific/Norfolk cause a duration calculation bug in the dotiw Ruby gem?","acceptedAnswer":{"@type":"Answer","text":"Norfolk Island permanently changed its UTC offset from +11:30 to +11:00 on 4 October 2015, a one-time tzdata rule change rather than a recurring seasonal DST transition. Code that hardcoded a ±1 hour DST correction had no way to represent this 30-minute permanent shift, causing a spurious 23 hours and 30 minutes to leak into what should have been a clean 1 year and 2 months calendar distance. The fix (PR #154) replaced the fixed hour assumption with a general offset_delta calculation. Anyone building duration or calendar-diff logic can track these tzdata-driven edge cases via daily.dev."}},{"@type":"Question","name":"Do other programming languages' time-humanizing libraries have the same DST and time zone offset bugs as Ruby's dotiw?","acceptedAnswer":{"@type":"Answer","text":"Testing date-fns, dayjs, moment.js, humanize, arrow, go-humanize, chrono-humanize, DateTime::diff, Carbon, Humanizer, PrettyTime, and Timex against the Dublin DST and Norfolk Island offset scenarios showed all were clean on Dublin, and all but Elixir's Timex were clean on Norfolk. Most avoid the bug structurally by rounding to a single largest unit rather than building a compound years/months/weeks/days/hours/minutes breakdown; PHP's Carbon is the exception that supports compound breakdowns yet still computes offsets correctly at the DateInterval level. Teams comparing date-time libraries across languages can weigh these tradeoffs using resources shared on daily.dev."}}]}
```

