Main Page | Modules | Directories | File List | File Members

Augmenting the Date object with some utility functions


Variables

Date _MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
Date SECOND = 1000
Date MINUTE = 60 * Date.SECOND
Date HOUR = 60 * Date.MINUTE
Date DAY = 24 * Date.HOUR
Date WEEK = 7 * Date.DAY
Date prototype getMonthDays
Date prototype getDayOfYear
Date prototype getWeekNumber
Date prototype equalsTo
Date prototype dateEqualsTo
Date prototype setDateOnly
Date prototype print
Zapatec Calendar prototype parseDate
Date prototype __msh_oldSetFullYear = Date.prototype.setFullYear
Date prototype setFullYear

Detailed Description

and variables.

Variable Documentation

Date _MD = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
 

Number of days in each month

Definition at line 2862 of file calendar.js.

Date SECOND = 1000
 

One second has 1000 milliseconds.

Definition at line 2864 of file calendar.js.

Date MINUTE = 60 * Date.SECOND
 

One minute has 60 seconds.

Definition at line 2865 of file calendar.js.

Date HOUR = 60 * Date.MINUTE
 

One hour has 60 minutes.

Definition at line 2866 of file calendar.js.

Date DAY = 24 * Date.HOUR
 

One day has 24 hours.

Definition at line 2867 of file calendar.js.

Date WEEK = 7 * Date.DAY
 

One week has 7 days.

Definition at line 2868 of file calendar.js.

Date prototype getMonthDays
  Returns the number of days in the month. The month parameter is optional; if not passed, the current month of this Date object is assumed.

Parameters:
month [int, optional] the month number, 0 for January.

Definition at line 2876 of file calendar.js.

Date prototype getDayOfYear
  Returns the number of the current day in the current year.

Definition at line 2889 of file calendar.js.

Date prototype getWeekNumber
  Returns the number of the week in year, as defined in ISO 8601.

Definition at line 2897 of file calendar.js.

Date prototype equalsTo
  Checks dates equality. Checks time too.

Definition at line 2908 of file calendar.js.

Date prototype dateEqualsTo
  Checks dates equality. Ignores time.

Definition at line 2917 of file calendar.js.

Date prototype setDateOnly
  Set only the year, month, date parts (keep existing time)

Definition at line 2924 of file calendar.js.

Date prototype print
 

Prints the date in a string according to the given format.

The format (str) may contain the following specialties:

  • %a - Abbreviated weekday name
  • %A - Full weekday name
  • %b - Abbreviated month name
  • %B - Full month name
  • %C - Century number
  • %d - The day of the month (00 .. 31)
  • %e - The day of the month (0 .. 31)
  • %H - Hour (00 .. 23)
  • %I - Hour (01 .. 12)
  • %j - The day of the year (000 .. 366)
  • %k - Hour (0 .. 23)
  • %l - Hour (1 .. 12)
  • %m - Month (01 .. 12)
  • %M - Minute (00 .. 59)
  • %n - A newline character
  • %p - "PM" or "AM"
  • %P - "pm" or "am"
  • %S - Second (00 .. 59)
  • %s - Number of seconds since Epoch
  • %t - A tab character
  • %W - The week number (as per ISO 8601)
  • %u - The day of week (1 .. 7, 1 = Monday)
  • %w - The day of week (0 .. 6, 0 = Sunday)
  • %y - Year without the century (00 .. 99)
  • %Y - Year including the century (ex. 1979)
  • %%% - A literal %% character

They are almost the same as for the POSIX strftime function.

Parameters:
str [string] the format to print date in.

Definition at line 2967 of file calendar.js.

Date parseDate
  Tries to identify the date represented in a string. If successful it also calls this.setDate which moves the calendar to the given date.

Parameters:
str [string] a date
fmt [string] the format to try to parse str in

Definition at line 3042 of file calendar.js.

Date prototype __msh_oldSetFullYear = Date.prototype.setFullYear
 

save a reference to the original setFullYear function

Definition at line 3139 of file calendar.js.

Date prototype setFullYear
  This function replaces the original Date.setFullYear() with a "safer" function which makes sure that the month or date aren't modified (unless in the exceptional case where the date is February 29 but the new year doesn't contain it).

Parameters:
y [int] the new year to move this date to

Definition at line 3149 of file calendar.js.