1 -- $Id: 350_set_datetime.lua,v 1.2 2005/02/24 23:08:03 cpressey Exp $
5 local set_datetime = function()
6 local cmds, date_tab, form, response
8 date_tab = os.date("*t")
12 name = _("Set Time and Date"),
14 "Enter the current date and time of day to set " ..
15 "this computer's internal timekeeping clock."
22 short_desc = _("Enter the current year (e.g. `2004')")
27 short_desc = _("Enter the current month (e.g. `07')")
32 short_desc = _("Enter the current day of month (e.g. `30')")
37 short_desc = _("Enter the current hour (e.g. `07')")
42 short_desc = _("Enter the current minute (e.g. `59')")
48 year = tostring(date_tab.year),
49 month = tostring(date_tab.month),
50 day = tostring(date_tab.day),
51 hour = tostring(date_tab.hour),
52 min = tostring(date_tab.min)
69 response = App.ui:present(form)
70 if response.action_id ~= "ok" then
75 year = tonumber(response.datasets[1].year),
76 month = tonumber(response.datasets[1].month),
77 day = tonumber(response.datasets[1].day),
78 hour = tonumber(response.datasets[1].hour),
79 min = tonumber(response.datasets[1].min)
83 -- Validate the given date and time.
86 if date_tab.year > 0 and
87 date_tab.month >= 1 and date_tab.month <= 12 and
88 date_tab.day >= 1 and date_tab.day <= 31 and
89 date_tab.hour >= 0 and date_tab.hour <= 23 and
90 date_tab.min >= 0 and date_tab.min <= 59 then
93 cmds:add("${root}${DATE} -n " .. string.format(
94 "%04d%02d%02d%02d%02d",
101 if cmds:execute() then
103 "The time and date have successfully been set."
108 "An error occurred while attempting to set " ..
114 "Please enter numbers within acceptable ranges " ..
115 "for year, month, day of month, hour, and minute."
124 name = _("Set Time and Date"),