some people have been wondering about the nifty clock on my lj... well... here ya go :)
some people are also wondering "what the hell would it be for?" ... well... when i load my friends page, i have one instance of it. i go away for a while or do something else at my computer and think "hey, i havent checked my friends page for a while... how old is this page? 3 hours, ok, its prolly time for a new instance of the page."
################################### # CLOCK COMPONENT # # kunzite1, component-help/179199 # # add to print_free_text(Page p) # ####################################################################################### # Clock # # by kunzite1 # # (adapted from lj:xevinx's post to journal script) # ####################################################################################### # USER SETTINGS # # # # set this to your time zone difference; for positive numbers leave the plus sign out # var int k1Ctime_difference = -8; # set this to 1 if it is between spring and fall # var int k1Cdaylight_savings = 1; # set this to 1 if you want 24 hr time # var int k1Cmilitary_time = 0; # set this to 1 if you want the date shown # var int k1Cshow_date = 1; # set this to the date seperator that you wish # # for example, a "/" or a "-" # var string k1Cseperator = "/"; # set this to the header of the component # var string k1Ctitle = "Clock"; ####################################################################################### # CLOCK START # ############### # DON'T need to mess with anything below var int k1Cyear = $p.time.year; var int k1Cday = $p.time.day; var int k1Chour = $p.time.hour + $k1Ctime_difference; var int k1Cmin = $p.time.min; var int k1Cmonth = $p.time.month; var string k1Cmeridian = ""; var string k1Cclock = ""; if($k1Cdaylight_savings){ $k1Chour = $k1Chour + 1; } # figure out days in month </span> var int k1Cmondays = 31; if($k1Cmonth == 4 or $k1Cmonth == 6 or $k1Cmonth == 9 or $k1Cmonth == 11) { $k1Cmondays = 30; } elseif($k1Cmonth == 2) { $k1Cmondays = ($k1Cyear % 4 == 0) ? 29 : 28; } if($k1Chour > 24) { # if your timezone is the day after system... $k1Chour = $k1Chour - 24; # figure out new hour value $k1Cday = $k1Cday + 1; # make sure to change day value if($k1Cday > $k1Cmondays) { # if your day is in the next month... $k1Cday = $k1Cday - $k1Cmondays; # figure out the new day $k1Cmonth = $k1Cmonth + 1; # change the month value if($k1Cmonth > 12) { # if your month is in the next year... $k1Cmonth = 1; # change the month value and $k1Cyear = $k1Cyear + 1; # change the year value } } } elseif($k1Chour < 0) { # otherwise, if your day is the day before... $k1Chour = 24 + $k1Chour; # change the hour and $k1Cday = $k1Cday - 1; # change the day value if($k1Cday < 1) { # if that puts you in the previous month... $k1Cmonth = $k1Cmonth - 1; # decrement the month value if($k1Cmonth < 1) { # if that puts you in the previous year... $k1Cmonth = 12; # set the new month value and $k1Cyear = $k1Cyear - 1; # decrement the year value } $k1Cmondays = 31; # figure out how many days are in this new month if($k1Cmonth == 4 or $k1Cmonth == 6 or $k1Cmonth == 9 or $k1Cmonth == 11) { $k1Cmondays = 30; } elseif($k1Cmonth == 2) { $k1Cmondays = ($k1Cyear % 4) == 0 ? 29 : 28; } $k1Cday = $k1Cmondays; # and change your day value to that. } } # if you dont want this to be in a component, # comment the next line AND the print_comp_footer() down a ways print_comp_header($k1Ctitle); # if you wish to center the clock within a # div or use any other html, this is the place # make sure you close the tags down there... # $k1Cclock = $k1Cclock + """<div align="center">"""; if($k1Cshow_date == 1){ if($k1Cmonth < 10){ $k1Cclock = $k1Cclock + """0$k1Cmonth"""; } else { $k1Cclock = $k1Cclock + """$k1Cmonth"""; } $k1Cclock = $k1Cclock + """$k1Cseperator"""; if($k1Cday < 10){ $k1Cclock = $k1Cclock + """0$k1Cday"""; } else { $k1Cclock = $k1Cclock + """$k1Cday"""; } $k1Cclock = $k1Cclock + """$k1Cseperator$k1Cyear<br />"""; } if($k1Cmilitary_time == 0){ if($k1Chour < 12){ $k1Cmeridian = "am"; } else { $k1Cmeridian = "pm"; } } if($k1Cmilitary_time == 1){ if($k1Chour < 10){ $k1Cclock = $k1Cclock + """0$k1Chour"""; } else { $k1Cclock = $k1Cclock + """$k1Chour"""; } } else { if($k1Chour > 12){ $k1Chour = $k1Chour - 12; } if($k1Chour == 0){ $k1Chour = 12; } if($k1Chour < 10){ $k1Cclock = $k1Cclock + """0$k1Chour"""; } else { $k1Cclock = $k1Cclock + """$k1Chour"""; } } $k1Cclock = $k1Cclock + """:"""; if($k1Cmin < 10){ $k1Cclock = $k1Cclock + """0$k1Cmin"""; } else { $k1Cclock = $k1Cclock + """$k1Cmin"""; } $k1Cclock = $k1Cclock + """$k1Cmeridian"""; # if you used any html to alter the appearance # of the clock, close the tags on the next line # $k1Cclock = $k1Cclock + """</div>"""; print $k1Cclock; # if you dont want this to be in a component, # comment the next line AND the print_comp_header($k1Ctitle) up a ways print_comp_footer(); ############# # CLOCK END # #############