DSL Ideas and Suggestions :: datetool starting time



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

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.
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?
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.
date function....hmmm...learning new things every day =o)
Next Page...
original here.