Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: datetool starting time, have the default be dynamic?< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Aug. 14 2005,13:57 QUOTE

Looking at the datetool I immediately noticed something that threw me off for a minute.  The initial date and time displayed are constants rather than the actual current date and time.

After messing around a little i came up with a possible solution:

Code Sample
execute("date +\"tmp_date = {%Y,%m,%d,%H,%M}\" >/tmp/datetool.tmp")
dofile("/tmp/datetool.tmp")
remove("/tmp/datetool.tmp")
This part sets up an array according to the current date adn time.

Code Sample
year_input.value=tmp_date[1]
month_input.value = format("%02u",tmp_date[2])
day_input.value = format("%02u",tmp_date[3])
hour_input.value = format("%02u",tmp_date[4])
min_input.value = format("%02u",tmp_date[5])
This inserts the appropriate part of the array into each box.

I don't fully understand what the string "%02u" means, but it seems to do the job  :D


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Aug. 14 2005,17:57 QUOTE

I debated whether to do that or not. On some very old computers the hardware clock won't update and hold the date. So then if you use the "dynamic" method, you must start from something very old, like1980 rather than 2005. Maybe, it is "time" that majority rules. I couldn't decide when I wrote it. The 02u is a format string for unsiged integers zero fill of width 2.
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Aug. 14 2005,19:37 QUOTE

I'm not clear on the "very old computers" issue, but I assumed that the above would be essentially the same as what you currently have in your script.  The only difference i can see is that when the Datetool is loaded the date command is run once to get the current date and time, and the initial input values are added from date's output rather than being hard-coded into the script.  I'm guessing that what you had in mind was quite a bit more precise and dynamic than what I did...something that would constantly update the current time?

--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Aug. 15 2005,17:19 QUOTE

I will go ahead and make it use the BIOS date to start with. You can use the date function in Lua therefore no need to use execute, bash date, tmp file or even an array. Look for this in 1.5.
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: Aug. 15 2005,18:28 QUOTE

date function....hmmm...learning new things every day =o)

--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
4 replies since Aug. 14 2005,13:57 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: datetool starting time

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code