From: rubin Date: Wed, 22 Jun 2005 21:58:40 +0000 (+0000) Subject: DURATION fixes X-Git-Tag: 1.9~645 X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/commitdiff_plain/ca22ccd3f182f70114edfc68ff8c9bb86b3e32c7 DURATION fixes --- diff --git a/ChangeLog.X3 b/ChangeLog.X3 index 9ceafd9..c6f9c7b 100644 --- a/ChangeLog.X3 +++ b/ChangeLog.X3 @@ -1,6 +1,12 @@ /*********************************************************************** X3 ChangeLog +2005-06-22 Alex Schumann + * src/chanserv.help: Improved DURATION help + + * src/tools.c: Changed 'M' duration to 30 days (not 31) as its + a better average. + 2005-05-27 Alex Schumann * src/chanserv.c: Improved usability of register command, fixed diff --git a/src/chanserv.help b/src/chanserv.help index 92e301c..efb9d33 100644 --- a/src/chanserv.help +++ b/src/chanserv.help @@ -280,11 +280,24 @@ "DOWNALL" ("/msg $C DOWNALL", "Executes the $bdown$b command for each channel you have access to.", "$uSee Also:$u down, up, upall"); -"DURATIONS" ("[y][M][w][d][h][m][[s]]", - "There is a standard syntax for durations that let you easily specify longer periods of time. A duration consists of one or more \"duration parts\", which are sequences of digits, separated by duration letters.", - "The valid duration letters are $by$b (for year, or 365 days), $bM$b (for month, or 31 days), $bw$b (for week, or 7 days), $bd$b (for day, or 24 hours), $bh$b (for hour, or 60 minutes), $bm$b (for minute, or 60 seconds), and $bs$b (for second). We know not all years are 365 days and not all months are 31 days, but we pretend they are for parsing durations.", - "If the last duration part does not have any letter to indicate the units, seconds are assumed.", - "$uExamples$u: 1y1M is 365 days plus 31 days; 1y1m is 365 days plus 1 minute; 1h30m45 is ninety minutes and forty-five seconds; and so forth."); +"DURATIONS" ( + "This is the syntax used for commands that require time durations. A time duration is made up of numbers and units. Multiple units may be used in a row.", + "The valid unit letters are:", + "$by$b - years (365 days)", + "$bM$b - months (30 days)", + "$bw$b - weeks (7 days)", + "$bd$b - days (24 hours)", + "$bh$b - hours (60 minutes)", + "$bm$b - minutes (60 seconds)", + "$bs$b - seconds", + "If the unit letter is not givin, seconds are assumed.", + "$b$b", + "$uExamples$u:", + "$b5d$b is 5 days.", + "$b1y2M$b is 1 year and 2 months (425 days.)", + "$b1d1h$b is 1 day and 1 hour (25 hours.)", + "$b1h25m30s$b is 1 hour, 25 minutes and 30 seconds." + ); "EMOTE" ("/msg $C EMOTE <#channel> ", "Makes $b$C$b send a CTCP ACTION message to the specified channel.", "$uSee Also:$u say"); diff --git a/src/tools.c b/src/tools.c index a778207..946f27a 100644 --- a/src/tools.c +++ b/src/tools.c @@ -588,7 +588,7 @@ TypeLength(char type) { switch (type) { case 'y': return 365*24*60*60; - case 'M': return 31*24*60*60; + case 'M': return 30*24*60*60; case 'w': return 7*24*60*60; case 'd': return 24*60*60; case 'h': return 60*60; @@ -598,6 +598,10 @@ TypeLength(char type) } } +/* This function is not entirely accurate as it does not take into account leap units + * or varying months. TODO: use proper dateadd functions to calculate real seconds + * from now for the units (eg 1M should be give us seconds till todays date next month) + */ unsigned long ParseInterval(const char *interval) {