From: "mame (Yusuke Endoh) via ruby-core" Date: 2025-08-08T03:59:28+00:00 Subject: [ruby-core:122934] [Ruby Feature#21533] Introduce `Time#am?` and `Time#pm?` Issue #21533 has been updated by mame (Yusuke Endoh). I'm not strongly opposed, but I have a slight doubt about `noon.pm?` returning `true`. According to NIST, designating noon as either a.m. or p.m. is technically incorrect: https://www.nist.gov/pml/time-and-frequency-division/times-day-faqs > To illustrate this, consider that "a.m." and "p.m." are abbreviations for "ante meridiem" and "post meridiem," which mean "before noon" and "after noon," respectively. Since noon is neither before noon nor after noon, a designation of either a.m. or p.m. is incorrect. Also, midnight is both twelve hours before noon and twelve hours after noon. A quick search for "12 p.m. noon" also brings up many articles and discussions arguing against the usage. I'm curious what others think. ---------------------------------------- Feature #21533: Introduce `Time#am?` and `Time#pm?` https://bugs.ruby-lang.org/issues/21533#change-114241 * Author: matheusrich (Matheus Richard) * Status: Open ---------------------------------------- This proposal adds two predicate methods to `Time`: ```ruby Time.utc(2000, 1, 1, 11, 59, 59).am? # => true Time.utc(2000, 1, 1, 12, 0, 0).pm? # => true ``` * `am?` returns true when the hour is less than 12. * `pm?` returns true when the hour is 12 or greater. These methods provide a clear and expressive way to branch logic based on time of day. For example: ```ruby def reminder_deferral_options options = [] options << ["Later today", "later_today"] if Time.now.am? options << ["Tomorrow morning", "tomorrow_morning"] options << ["Pick a date/time���", "custom"] options end ``` This is a common pattern in applications involving reminders and scheduling. The method names are intuitive, and the semantics are well understood. The implementation is in [this Pull Request](https://github.com/ruby/ruby/pull/14133). -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/