-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Answer “how old are you” and “age” queries #363
base: main
Are you sure you want to change the base?
Conversation
The script creation date is obtained from the git history. Resolves Raku#361.
I'm not completely satisfied with how the question is answered yet in that a creation date is not a good answer for an age query. I'd like to have something like "$y years and $d days ago", but I got lost a little in (leap) date arithmetic. Sadly using a Duration will be inaccurate as a difference of 366 days might be "1 year" or "1 year and 1 day", depending on what the two dates were... But I want to ask first: Do you agree that an answer formatted like above is more desirable than the creation timestamp? |
There's a
First I was a bit confused, now I understand that you're totally right… hmm… Is there any module in the ecosystem? Generally I don't want any more dependencies in whateverable, there are already too many, but I can do an exception… :) |
with birthday { | ||
“I was created on $_” | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Bots automatically gist uncaught exceptions, there's no need. You can of course grumble ‘something went wrong’
but I don't see any good reason. In this case exception is totally fine, although I'm a bit confused as to when it'll trigger given that ‘no birthday data available’ message is there? Maybe wrap the whole thing in a try/catch and just output ‘no birthday data available no matter what goes wrong? The feature is more like an easter egg, so I'm not too concerned about debugging.
Also, change it to ‘I don't remember’, I think that's funnier.
@@ -108,6 +108,29 @@ multi method irc-to-me(Message $msg where .text ~~ /:i^ uptime \s* $/) { | |||
~ “implementing {.language_name} {.language_version}.” | |||
}) | |||
} | |||
#| Get the oldest commit DateTime for $*PROGRAM. Needs $*CWD to point to the whateverable git repository. | |||
sub term:<birthday> { | |||
my $dates = run :out, ‘git’, ‘log’, ‘--follow’, ‘--date-order’, ‘--format=%aI’, $*PROGRAM.relative; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to write run like this, but nowadays I'd do run :out, <git log --follow --date-order --format=%aI>, $*PROGRAM.relative
.
Any updates? :) I'd love to merge this. |
The script creation date is obtained from the git history. Resolves #361.