I was working on a piece of a script that checks the file written date and compares it to the current system date. The format of the two dates is different. for the system date I used
and it returns a string for instance for today it would return
mm = 02
dd = 09
yyyy = 2004
dow = 2
I then wanted to convert this to a comparable format that is retrieved by the File.GetAttributes (table.WriteDate). Which is returned as
Monday, February 09, 2004
To do this I created two tables and had to convert the above GetDate information to a number.
Here are the tables and script, but is there an easier way?
[code]--Month table
month = {};
month[1] = "January";
month[2] = "February";
month[3] = "March";
month[4] = "April";
month[5] = "May";
month[6] = "June";
month[7] = "July";
month[8] = "August";
month[9] = "September";
month[10] = "October";
month[11] = "November";
month[12] = "December";
--Day of the Week Table
dayoftheweek = {};
dayoftheweek[1] = "Sunday";
dayoftheweek[2] = "Monday";
dayoftheweek[3] = "Tuesday";
dayoftheweek[4] = "Wednesday";
dayoftheweek[5] = "Thursday";
dayoftheweek[6] = "Friday";
dayoftheweek[7] = "Saturday";
--Get date information and convert month and day of week to numbers
mm = System.GetDate(DATE_FMT_MONTH);
mm = String.ToNumber(mm);
dd = System.GetDate(DATE_FMT_DAY);
yyyy = System.GetDate(DATE_FMT_YEAR);
dow = System.GetDate(DATE_FMT_DAYOFWEEK);
dow = String.ToNumber(dow);
--Display information as "DayOfWeek, Month dd, yyyy"
Dialog.Message("Date", "The current date is "..date.."\r\nor "..dayoftheweek[dow]..", "..month[mm].." "..dd..", "..yyyy, MB_OK, MB_ICONNONE, MB_DEFBUTTON1)
[\code]
Code:
mm = System.GetDate(DATE_FMT_MONTH); dd = System.GetDate(DATE_FMT_DAY); yyyy = System.GetDate(DATE_FMT_YEAR); dow = System.GetDate(DATE_FMT_DAYOFWEEK);
mm = 02
dd = 09
yyyy = 2004
dow = 2
I then wanted to convert this to a comparable format that is retrieved by the File.GetAttributes (table.WriteDate). Which is returned as
Monday, February 09, 2004
To do this I created two tables and had to convert the above GetDate information to a number.
Here are the tables and script, but is there an easier way?
[code]--Month table
month = {};
month[1] = "January";
month[2] = "February";
month[3] = "March";
month[4] = "April";
month[5] = "May";
month[6] = "June";
month[7] = "July";
month[8] = "August";
month[9] = "September";
month[10] = "October";
month[11] = "November";
month[12] = "December";
--Day of the Week Table
dayoftheweek = {};
dayoftheweek[1] = "Sunday";
dayoftheweek[2] = "Monday";
dayoftheweek[3] = "Tuesday";
dayoftheweek[4] = "Wednesday";
dayoftheweek[5] = "Thursday";
dayoftheweek[6] = "Friday";
dayoftheweek[7] = "Saturday";
--Get date information and convert month and day of week to numbers
mm = System.GetDate(DATE_FMT_MONTH);
mm = String.ToNumber(mm);
dd = System.GetDate(DATE_FMT_DAY);
yyyy = System.GetDate(DATE_FMT_YEAR);
dow = System.GetDate(DATE_FMT_DAYOFWEEK);
dow = String.ToNumber(dow);
--Display information as "DayOfWeek, Month dd, yyyy"
Dialog.Message("Date", "The current date is "..date.."\r\nor "..dayoftheweek[dow]..", "..month[mm].." "..dd..", "..yyyy, MB_OK, MB_ICONNONE, MB_DEFBUTTON1)
[\code]
Comment