Xin Calendar 2 Step-by-step: The helper functions
Say we have a date format of [ Mon. dd (day), yyyy ] which will give us some nice reading dates such as [ Jul. 28 (Wed), 2004 ], but we would have some hard time if we want to validate such a date or compare two dates. Luckily with the helper functions, this is an easy job.
Xin Calendar 2 not only lets us choose our own date format but also provides us some helper functions to deal with the dates in our own date format.
The helper functions we currently have are:
toCalendarDate(date)
... takes a JS date parameter and returns the date string in date format
toJSDate(date)
... takes a date string parameter in date format and returns the JS date
getCurrentDate()
... returns today's date in date format
checkDate(date)
... takes a date string parameter, returns 0 if it's compliant to the date format, or returns 1 if it is not, or returns 2 if it's empty or undefined
compareDates(date1, date2)
... takes two date string parameters, returns 0 if they are the same date, or returns 1 if date1 comes later than date2, or returns -1 if date1 comes earlier than date2
getDateNumbers(date)
... takes a date string parameter, returns an array of strings for its year, month and day
[The user functions] [Back to index page]
# # #