«
jsDate

Namespace jsDate.formats

Namespace to hold format codes and format shortcuts. "perl" and "php" format codes and shortcuts are defined by default. Additional codes and shortcuts can be added like:

jsDate.formats["perl"] = {
    "codes": {
        matcher: /someregex/,
        Y: "fullYear",  // name of "get" method without the "get",
        ...,            // more codes
    },
    "shortcuts": {
        F: '%Y-%m-%d',
        ...,            // more shortcuts
    }
};

Additionally, ISO and SQL shortcuts are defined and can be accesses via: jsDate.formats.ISO and jsDate.formats.SQL

Defined in: jsdate.js.

Field Summary
perl Perl format codes and shortcuts for strftime.
php PHP format codes and shortcuts for strftime.
Field Detail
jsDate.formats.perl
Perl format codes and shortcuts for strftime. A hash (object) of codes where each code must be an array where the first member is the name of a Date.prototype or jsDate.prototype function to call and optionally a second member indicating the number to pass to addZeros()

The following format codes are defined:

Code    Result                    Description
== Years ==           
%Y      2008                      Four-digit year
%y      08                        Two-digit year

== Months ==          
%m      09                        Two-digit month
%#m     9                         One or two-digit month
%B      September                 Full month name
%b      Sep                       Abbreviated month name

== Days ==            
%d      05                        Two-digit day of month
%#d     5                         One or two-digit day of month
%e      5                         One or two-digit day of month
%A      Sunday                    Full name of the day of the week
%a      Sun                       Abbreviated name of the day of the week
%w      0                         Number of the day of the week (0 = Sunday, 6 = Saturday)

== Hours ==           
%H      23                        Hours in 24-hour format (two digits)
%#H     3                         Hours in 24-hour integer format (one or two digits)
%I      11                        Hours in 12-hour format (two digits)
%#I     3                         Hours in 12-hour integer format (one or two digits)
%p      PM                        AM or PM

== Minutes ==         
%M      09                        Minutes (two digits)
%#M     9                         Minutes (one or two digits)

== Seconds ==         
%S      02                        Seconds (two digits)
%#S     2                         Seconds (one or two digits)
%s      1206567625723             Unix timestamp (Seconds past 1970-01-01 00:00:00)

== Milliseconds ==    
%N      008                       Milliseconds (three digits)
%#N     8                         Milliseconds (one to three digits)

== Timezone ==        
%O      360                       difference in minutes between local time and GMT
%Z      Mountain Standard Time    Name of timezone as reported by browser
%G      06:00                     Hours and minutes between GMT

== Shortcuts ==       
%F      2008-03-26                %Y-%m-%d
%T      05:06:30                  %H:%M:%S
%X      05:06:30                  %H:%M:%S
%x      03/26/08                  %m/%d/%y
%D      03/26/08                  %m/%d/%y
%#c     Wed Mar 26 15:31:00 2008  %a %b %e %H:%M:%S %Y
%v      3-Sep-2008                %e-%b-%Y
%R      15:31                     %H:%M
%r      03:31:00 PM               %I:%M:%S %p

== Characters ==      
%n      \n                        Newline
%t      \t                        Tab
%%      %                         Percent Symbol

Formatting shortcuts that will be translated into their longer version. Be sure that format shortcuts do not refer to themselves: this will cause an infinite loop.

Format codes and format shortcuts can be redefined after the jsDate module is imported.

Note that if you redefine the whole hash (object), you must supply a "matcher" regex for the parser. The default matcher is:

/()%(#?(%|[a-z]))/i

which corresponds to the Perl syntax used by default.

By customizing the matcher and format codes, nearly any strftime functionality is possible.


									
								
									
										
										
										
										
				
								
jsDate.formats.php
PHP format codes and shortcuts for strftime. A hash (object) of codes where each code must be an array where the first member is the name of a Date.prototype or jsDate.prototype function to call and optionally a second member indicating the number to pass to addZeros()

The following format codes are defined:

Code    Result                    Description
=== Days ===        
%a      Sun through Sat           An abbreviated textual representation of the day
%A      Sunday - Saturday         A full textual representation of the day
%d      01 to 31                  Two-digit day of the month (with leading zeros)
%e      1 to 31                   Day of the month, with a space preceding single digits.
%j      001 to 366                Day of the year, 3 digits with leading zeros
%u      1 - 7 (Mon - Sun)         ISO-8601 numeric representation of the day of the week
%w      0 - 6 (Sun - Sat)         Numeric representation of the day of the week
                                 
=== Week ===                     
%U      13                        Full Week number, starting with the first Sunday as the first week
%V      01 through 53             ISO-8601:1988 week number, starting with the first week of the year 
                                  with at least 4 weekdays, with Monday being the start of the week
%W      46                        A numeric representation of the week of the year, 
                                  starting with the first Monday as the first week
=== Month ===                    
%b      Jan through Dec           Abbreviated month name, based on the locale
%B      January - December        Full month name, based on the locale
%h      Jan through Dec           Abbreviated month name, based on the locale (an alias of %b)
%m      01 - 12 (Jan - Dec)       Two digit representation of the month

=== Year ===                     
%C      19                        Two digit century (year/100, truncated to an integer)
%y      09 for 2009               Two digit year
%Y      2038                      Four digit year

=== Time ===                     
%H      00 through 23             Two digit representation of the hour in 24-hour format
%I      01 through 12             Two digit representation of the hour in 12-hour format
%l      1 through 12              Hour in 12-hour format, with a space preceeding single digits
%M      00 through 59             Two digit representation of the minute
%p      AM/PM                     UPPER-CASE 'AM' or 'PM' based on the given time
%P      am/pm                     lower-case 'am' or 'pm' based on the given time
%r      09:34:17 PM               Same as %I:%M:%S %p
%R      00:35                     Same as %H:%M
%S      00 through 59             Two digit representation of the second
%T      21:34:17                  Same as %H:%M:%S
%X      03:59:16                  Preferred time representation based on locale, without the date
%z      -0500 or EST              Either the time zone offset from UTC or the abbreviation
%Z      -0500 or EST              The time zone offset/abbreviation option NOT given by %z

=== Time and Date ===            
%D      02/05/09                  Same as %m/%d/%y
%F      2009-02-05                Same as %Y-%m-%d (commonly used in database datestamps)
%s      305815200                 Unix Epoch Time timestamp (same as the time() function)
%x      02/05/09                  Preferred date representation, without the time

=== Miscellaneous ===            
%n        ---                     A newline character (\n)
%t        ---                     A Tab character (\t)
%%        ---                     A literal percentage character (%)

									
								
									
										
										
										
										
				
								
©2010 Chris Leonello

Documentation generated using JsDoc Toolkit 2.4.0 on Fri Dec 03 2010 15:36:44 GMT-0500 (EST)