Changing the output of countup

Is it possible to create a countup command that will only display years/month/days (without hh/mm/ss)?

Hey @Cali_Condor!

Yes, it’s doable using a RegExp, we can match the first part of the sentence and adapt to the varying length:

/(\d+\syear(s\b)?\s?)?(\d+\smonth(s\b)?\s?)?(\d+\sday(s\b)?\s?)?/

For example, on the following sentence the RegExp will match:

"3 years 7 months 2 days 18 hours 20 minutes 14 seconds in the future"
3 years 7 months 2 days ,3 years ,s,7 months ,s,2 days ,s

If we remove any years/months/days, or if any are singular instead of plural, it’ll still match the correct first part of the sentence. Of course there is waste, but we can get rid of it by only using the first match.

So here’s the final command:

!addcom !command_name $(eval t=`$(countup TIME/DATE)`.match(/(\d+\syear(s\b)?\s?)?(\d+\smonth(s\b)?\s?)?(\d+\sday(s\b)?\s?)?/); t[0]+` in the future`)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.