This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Format of date

Old posts that have not been replied to for several years.
Locked
j
jagg

Format of date

Post by jagg »

Hi,

today is eg 12/19/2002 then the following line

Code: Select all

clock format [clock seconds] -format "%b %d"
will post Dec 19

so far so good....

But how must the line looks like to get the date from tormorrow (Dec 20) and the day after (Dec 21)?

Thanks
jagg
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Re: Format of date

Post by strikelight »

jagg wrote:Hi,

today is eg 12/19/2002 then the following line

Code: Select all

clock format [clock seconds] -format "%b %d"
will post Dec 19

so far so good....

But how must the line looks like to get the date from tormorrow (Dec 20) and the day after (Dec 21)?

Thanks
jagg
Well if [clock seconds] is today, and knowing that [clock seconds] returns the time in unix format (that being the number of seconds since a certain date), then logically it would follow you would want [clock seconds] + (24 * 60 * 60) [where 24 is hours in a day, 60 is minutes in an hour, and 2nd 60 is the seconds in a minute -> which gives the number of seconds in a day]..

So to find the date x amount of days after today you would use the formula... [clock seconds] + ($x * 24 * 60 * 60) ...

It's just simple math.


I've given you the pseudo code, I'll let you figure out the actual code, which isn't much to change.
j
jagg

Post by jagg »

Ok, test it with

Code: Select all

proc pub:test {nick host hand chan arg} {

set tomorrow [clock scan "tomorrow"]
set dayaftertomorrow [expr $tomorrow + (24 * 60 * 60)]

putserv "PRIVMSG $chan : Tomorrow: [clock format $tomorrow -format "%b %d"] "
putserv "PRIVMSG $chan : The day after: [clock format $dayaftertomorrow -format "%b %d"] "
}
...and it works :)
Locked