WizardStorm Think Group is pleased to provide a full compliment of Date & Time functions which are compatible with standard database DateTime strings. Please use and enjoy! Please report any bugs found to: [email protected].
The provided functions are:
//generates YYYY-MM-DD string of current date
string GetCurrentDate();
//generates HH:MM:SS string of current time
string GetCurrentTime();
//generates YYYY-MM-DD HH:MM:SS string of current date and time
string GetCurrentDateTime();
//generates a string YYYY-MM-DD out of given dates
string GetDateString(int nYear, int nMonth, int nDay);
//generates a string HH:MM:SS out of given times
string GetTimeString(int nHour, int nMinute, int nSecond);
//generates a string YYYY-MM-DD HH:MM:SS out of given dates and times
string GetDateTimeString(int nYear, int nMonth, int nDay, int nHour, int nMinute, int nSecond);
//returns a year, month or day portion of a date as an integer
//usage: nDay = ParseDateString("1977-09-07", "day");
int ParseDateString(string sDateString, string sOption);
//returns a hour, minute or second portion of a time as an integer
//usage: nHour = ParseTimeString("17:03:21", "hour");
int ParseTimeString(string sTimeString, string sOption);
//returns a year, month, day, hour, minute or second portion of a DateTime as an integer
//usage: nHour = ParseDateTimeString("1977-09-07 17:03:21", "hour");
int ParseDateTimeString(string sDateTimeString, string sOption);
//usage: iNumOfDaysElapsed = GetDateDifference("1352-1-14", "1977-7-9", "days");
//uses NWN calendar settings for # of days in month (28)
//values for sOption are: years, months, days
//note: sDate1 MUST BE <= SDate2
//i.e. GetDateDifference("1356-01-14", "1355-01-14", "months") will return -1
int GetDateDifference(string sDate1, string sDate2, string sOption);
//usage: iNumOfMinutesElapsed = GetTimeDifference("06:14:22", "14:49:31", "minutes");
//uses NWN calendar settings for # of hours in day (0-23)
//values for sOption are: hours, minutes, seconds
//note: sTime1 MUST BE <= STime2
//i.e. GetTimeDifference("16:14:22", "14:49:31", "minutes") will return -1
int GetTimeDifference(string sTime1, string sTime2, string sOption);
//usage: sDueDate = GetFutureDate(GetCurrentDate(), 7, 1, 0);
//this will return a string 7 days and 1 month in the future
string GetFutureDate(string sStartDate, int nIncYear = 0, int nIncMonth = 0, int nIncDay = 0);
//usage: sBDay = GetPastDate(GetCurrentDate(), 0, 0, 50);
//this will return a string 50 years in the past
string GetPastDate(string sStartDate, int nIncYear = 0, int nIncMonth = 0, int nIncDay = 0);
//purpose: test if sDate1 == sDate2
int CompareDates(string sDate1, string sDate2);
//Converts sDateTime to Seconds
int DateTimeToSeconds(string sDateTime);
Posted by Reisiger at 2007-01-30 08:55:10 Voted 10.00 on 01/30/07
Exactely what I've been looking for :-)
Posted by puket at 2007-01-15 11:22:55 Voted 10.00 on 01/15/07
very useful,no function is missing so far to work with the time in a mod.A 10 is is ok.
Posted by cricket at 2007-01-03 11:08:20 Voted 10.00 on 01/03/07
I have found these very useful!
Thx!
Posted by Urlord at 2007-01-02 23:11:45 Voted 9.75 on 01/02/07
If you like what you see with this set of Date & Time functions, please vote and/or comment. If you can think of anything that was left out or would be better another way, let us know. Our goal is to produce nothing but the very best.
10 - A Masterpiece, Genuinely Groundbreaking 9 - Outstanding, a Must Have 8 - Excellent, Recommended to Anyone 7 - Very Good, Deserves a Look 6 - Good, Qualified Recommendation 5 - Fair, Solid yet Unremarkable 4 - Some Merit, Requires Improvements 3 - Poor Execution, Potential Unrealized 2 - Very Little Appeal 1 - Not Recommended to Anyone