Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Henrik Nyh
Henrik Nyh
@henrik@ruby.social  ·  activity timestamp 3 weeks ago

#Ruby pet peeve: sloppily parsing a wide range of date or time formats when only one is intended.

`Date.parse(my_string)` is not your only option and handles all kinds of messy, ambiguous formats like like "5 jan" or "1/5".

`Date.iso8601("2026-01-30")` will only allow that format, which in my experience is usually intended.

Or `Date.strptime("2026-30-01", "%Y-%d-%m")` if you are American or otherwise encumbered.

  • Copy link
  • Flag this post
  • Block
mudge
mudge
@mudge@ruby.social  ·  activity timestamp 3 weeks ago

@henrik don’t forget to celebrate 23 Dogs day https://x.com/tomstuart/status/668795250190757888

X (formerly Twitter)
View
  • Copy link
  • Flag this comment
  • Block
Henrik Nyh
Henrik Nyh
@henrik@ruby.social  ·  activity timestamp 3 weeks ago

@mudge Haha love it.

Would you believe 30 Dogs day is TODAY 😮

```
> Date.parse("30 Dogs")
Fri, 30 Jan 2026
```

  • Copy link
  • Flag this comment
  • Block
Martin Frost
Martin Frost
@frost@camp.smolnet.org  ·  activity timestamp 3 weeks ago

@henrik @mudge One of my favourites is `Date.parse("I am a monkey")`.

  • Copy link
  • Flag this comment
  • Block
Henrik Nyh
Henrik Nyh
@henrik@ruby.social  ·  activity timestamp 3 weeks ago

@frost @mudge Hah, also fun. And "I am a tuekey" gets you the next day.

  • Copy link
  • Flag this comment
  • Block
Martin Frost
Martin Frost
@frost@camp.smolnet.org  ·  activity timestamp 3 weeks ago

@henrik @mudge and the day after that, you can be a wedding photographer

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.2-alpha.32 no JS en
Federation disabled
Log in
Instance logo
  • Explore
  • About
  • Members
  • Code of Conduct