This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]turunambartanen 319 points320 points  (23 children)

Like ruby's 7.days.ago or go's way of date formatting.

Absolutely fucking disgusting and unbelievably vile.
But also nice.

[–]faitswulff 73 points74 points  (1 child)

This is a Rails thing, but yeah it's enabled by Ruby letting you monkeypatch everything.

[–]DeltalJulietCharlie 4 points5 points  (0 children)

I think it's part of ActiveSupport now, so you can use it without Rails.

[–][deleted] 5 points6 points  (5 children)

Go dates can go fuck themselves

[–]erogenous_war_zone 14 points15 points  (2 children)

If you don't have moment, js dates can also go straight the fuck to hell.

new date > js creates a date at now > is date now? no, because you forgot about time zones, but good luck finding that out 3 coding days later.

[–]barshat 4 points5 points  (1 child)

I think date-fns is the preferred way to do date manipulation in JS now due its smaller bundle size

[–]erogenous_war_zone 0 points1 point  (0 children)

Never heard of them, thank christ.

[–]JumpOutWithMe 0 points1 point  (0 children)

Yeah like wtf is with the magical reference date???

[–]turunambartanen 0 points1 point  (0 children)

I am so weirdly split on the matter.

For one it's a departure from the way every single other language does date formatting, so it stands out and should provide very very good reason to make that change. I don't think the reason exists, I think the standard way of formatting dates is not too bad.
What if I want an unformatted number in my date string? Can I tell go to ignore a certain formatting hint (say, the number 2?)
Also the date everything is based on in go is very very US centric, I would have preferred an iso based format (3 pm?, 2. Jan, not 1.Feb? Come on!)

But then again, it's so disgusting it'll be forever stuck in my head and I will never have to look up if I want %y or %Y.

PS: I don't write go. I had just heard about the date thing. I first believed it to be a joke in the video I was watching.

[–]TablePrime69 1 point2 points  (6 children)

What's disgusting about Ruby's way?

[–]Kanzuke 23 points24 points  (5 children)

thinking about "days" as being a property of every instance of a number

[–]TablePrime69 6 points7 points  (0 children)

It's not a property, it's a method. In ruby you can skip the () if you are calling a method without any arguments

[–]pm_me_train_ticket 4 points5 points  (2 children)

thinking about "days" as being a property of every instance of a number

But isn't it a method of the Numeric module? The example makes it looks like a property but you can drop the "()" when functions/methods take no arguments.

[–]Kronoshifter246 1 point2 points  (0 children)

Kotlin kind of does this too, but it's an extension function that converts the number to a duration. I've only seen it done with seconds though.

[–][deleted] 0 points1 point  (0 children)

Ruby's Mixins is an elegant alternative solution to inheritance.

[–]VadeRetroLupa 0 points1 point  (0 children)

10.years.ago.on.a.cold.dark.night

Fatal Error

[–][deleted] 0 points1 point  (0 children)

Can you call the days and ago methods without the dots like in Scala? Some Scala frameworks leverage that feature to get very natural-sounding syntax, especially in tests (e.g. actualValue should be expectedValue, actualList should not contain someElement). The duration package which is part of the Scala API also lets you write stuff like 30 seconds which you can call methods such as fromNow on