I'm new to using Ruby and this tickled me pink
-
This is exactly why I love PowerShell.
Need the [DateTime] object from 10 years ago? No biggie, just chuck
(Get-Date).AddYears(-10)
down your console.Need it in a specific timezone? That one's trickier, but since PowerShell can do .Net, run this:
$TargetDateTime = (Get-Date).AddYears(-10) $TargetTimeZone = "India Standard Time" $tz = [TimeZoneInfo]::FindSystemTimeZoneById($TargetTimeZone) $utcOffset = $tz.GetUtcOffset($TargetDateTime) [DateTimeOffset]::new($TargetDateTime.Ticks, $utcOffset)
And you get a DateTimeOffset object, which is this beauty:
DateTime : 25/08/2015 23:15:14 UtcDateTime : 25/08/2015 17:45:14 LocalDateTime : 25/08/2015 19:45:14 Date : 25/08/2015 00:00:00 Day : 25 DayOfWeek : Tuesday DayOfYear : 237 Hour : 23 Millisecond : 421 Microsecond : 428 Nanosecond : 600 Minute : 15 Month : 8 Offset : 05:30:00 TotalOffsetMinutes : 330 Second : 14 Ticks : 635761413144214286 UtcTicks : 635761215144214286 TimeOfDay : 23:15:14.4214286 Year : 2015
DateTime
is the time in your target timezone,UtcDateTime
is, well, the UTC time, andLocalDateTime
is the time on host you ran the commands on. -
What is the purpose of this comment.
You didn't seem to be ashamed of admitting to asking an LLM a question as if it was helpful, wise, or respectable for you to have done. You should be.
-
You didn't seem to be ashamed of admitting to asking an LLM a question as if it was helpful, wise, or respectable for you to have done. You should be.
This is a poor perspective to have on things towards a stranger on the internet. I hope you’re just having a bad day and that things get better.
-
People still use ruby?
You probably use it everyday and didn't know it https://github.blog/engineering/architecture-optimization/building-github-with-ruby-and-rails/
-
This post did not contain any content.wrote last edited by [email protected]
There's two of these threads?! Well ok here's the same comment.
10.years.ago On.a.cold.dark.night There.was.someone.killed 'Neath.the.town.hall.lights There.were.few.at.the.scene Though.they.all.agreed That.the.slayer.who.ran Looked.a.lot.like.me
-
ahahaha oh come on, the comment was clearly a joke. To be honest, I'd be far more interested in gothly serious sam on the left.
wrote last edited by [email protected]Can't see the comment but judging by the uname you're right, that's Frank Reynolds' fake name from It's Always Sunny, Mantis Toboggan M.D. lmao. I'd wager 95% of what that person says is at least intended to be a joke/satirical/etc.
-
The comparison is somewhat awkward, because the rails example presumably produces a date, while the python one is referring to an interval of time.
Just from the meme it's not obvious which was the actual intended use, so labeling either as inaccurate requires us to make assumptions.Personally, the concept of "10 years ago" is a bit nebulous to me. If today is February 29th, is ten years ago March 1st? Doesn't seem right. Or particularly useful.
Ruby should add 10.years.ago.today
-
timedelta
marks time in days, seconds, and microseconds. It doesn't take leap years into account because the concept of years is irrelevant totimedelta
. If you need to account for leap years, you need a different API.365.25*10 would at least get you closer.
-
Yeah its a rails only thing. Rubys biggest issue is its much too intelligent for its own good. Its implicit rather than pythons explicit. Most of the time. That and it's hard to find out where Ruby starts and rails ends.
That being said I made a ton of good money on rails back about 15 or so years ago. Still excellent for starting out.
Ruby’s biggest issue is rails. Ruby is such a beautiful and highly functional language and yet everyone’s experience with it is rails’ horrific metaprogramming magic. I’ve had numerous people tell me they hate Ruby, and yet when I dig deeper I find out that they don’t actually understand where Ruby ends and rails starts and all of their problems lies on rails side. The majority of people I’ve shown that have come to actually like Ruby where they hated it before.
-
You probably use it everyday and didn't know it https://github.blog/engineering/architecture-optimization/building-github-with-ruby-and-rails/
That explains a lot about how GitHub works… or doesn’t.