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.

Checking if time is between x and y

Old posts that have not been replied to for several years.
Locked
S
SomeGuy
Voice
Posts: 13
Joined: Sat May 01, 2004 5:25 pm

Checking if time is between x and y

Post by SomeGuy »

Ok, my script looks like this:

Code: Select all

set start_stamp [clock scan "$hour:$min"] 

set 1hour_before [expr {$start_stamp - (60 * 60)}] 
set 1hour_before_format [clock format $1hour_before -format "%H:%M"] 

set 1hour_after [expr {$start_stamp + (60 * 60)}] 
set 1hour_after_format [clock format $1hour_after -format "%H:%M"] 


Now how do I check if the time (thats in database file) is between $1hour_before_format and $1hour_after_format and only on the current day?
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

#first get the time from the file and set it to a variable
#then make sure it is in unixformat (like it is returned from the clock scan command

# this is just an example
set time [clock scan "19:20"]

#do the check..
if {$time < $1hour_after && $time > $1hour_before} { 
  #it is between the vars... do something here
}
Elen sila lúmenn' omentielvo
Locked