ÿþ/ *  
   *   D a t e   p r o t o t y p e   e x t e n s i o n s .   D o e s n ' t   d e p e n d   o n   a n y  
   *   o t h e r   c o d e .   D o e n s ' t   o v e r w r i t e   e x i s t i n g   m e t h o d s .  
   *  
   *   A d d s   d a y N a m e s ,   a b b r D a y N a m e s ,   m o n t h N a m e s   a n d   a b b r M o n t h N a m e s   s t a t i c   p r o p e r t i e s   a n d   i s L e a p Y e a r ,  
   *   i s W e e k e n d ,   i s W e e k D a y ,   g e t D a y s I n M o n t h ,   g e t D a y N a m e ,   g e t M o n t h N a m e ,   g e t D a y O f Y e a r ,   g e t W e e k O f Y e a r ,  
   *   s e t D a y O f Y e a r ,   a d d Y e a r s ,   a d d M o n t h s ,   a d d D a y s ,   a d d H o u r s ,   a d d M i n u t e s ,   a d d S e c o n d s   m e t h o d s  
   *  
   *   C o p y r i g h t   ( c )   2 0 0 6   J ö r n   Z a e f f e r e r   a n d   B r a n d o n   A a r o n   ( b r a n d o n . a a r o n @ g m a i l . c o m   | |   h t t p : / / b r a n d o n a a r o n . n e t )  
   *  
   *   A d d i t i o n a l   m e t h o d s   a n d   p r o p e r t i e s   a d d e d   b y   K e l v i n   L u c k :   f i r s t D a y O f W e e k ,   d a t e F o r m a t ,   z e r o T i m e ,   a s S t r i n g ,   f r o m S t r i n g   -  
   *   I ' v e   a d d e d   m y   n a m e   t o   t h e s e   m e t h o d s   s o   y o u   k n o w   w h o   t o   b l a m e   i f   t h e y   a r e   b r o k e n !  
   *    
   *   D u a l   l i c e n s e d   u n d e r   t h e   M I T   a n d   G P L   l i c e n s e s :  
   *       h t t p : / / w w w . o p e n s o u r c e . o r g / l i c e n s e s / m i t - l i c e n s e . p h p  
   *       h t t p : / / w w w . g n u . o r g / l i c e n s e s / g p l . h t m l  
   *  
   * /  
  
 / * *  
   *   A n   A r r a y   o f   d a y   n a m e s   s t a r t i n g   w i t h   P a z a r .  
   *    
   *   @ e x a m p l e   d a y N a m e s [ 0 ]  
   *   @ r e s u l t   ' P a z a r '  
   *  
   *   @ n a m e   d a y N a m e s  
   *   @ t y p e   A r r a y  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   * /  
 D a t e . d a y N a m e s   =   [ ' P a z a r ' ,   ' P a z a r t e s i ' ,   ' S a l 1' ,   ' Ç a r _a m b a ' ,   ' P e r _e m b e ' ,   ' C u m a ' ,   ' C u m a r t e s i ' ] ;  
  
 / * *  
   *   A n   A r r a y   o f   a b b r e v i a t e d   d a y   n a m e s   s t a r t i n g   w i t h   S u n .  
   *    
   *   @ e x a m p l e   a b b r D a y N a m e s [ 0 ]  
   *   @ r e s u l t   ' S u n '  
   *  
   *   @ n a m e   a b b r D a y N a m e s  
   *   @ t y p e   A r r a y  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   * /  
 D a t e . a b b r D a y N a m e s   =   [ ' P z ' ,   ' P z t ' ,   ' S a l 1' ,   ' Ç r _' ,   ' P e r _' ,   ' C m ' ,   ' C m t ' ] ;  
  
 / * *  
   *   A n   A r r a y   o f   m o n t h   n a m e s   s t a r t i n g   w i t h   J a n u r a r y .  
   *    
   *   @ e x a m p l e   m o n t h N a m e s [ 0 ]  
   *   @ r e s u l t   ' O c a k '  
   *  
   *   @ n a m e   m o n t h N a m e s  
   *   @ t y p e   A r r a y  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   * /  
 D a t e . m o n t h N a m e s   =   [ ' O c a k ' ,   ' ^u b a t ' ,   ' M a r t ' ,   ' N i s a n ' ,   ' M a y 1s ' ,   ' H a z i r a n ' ,   ' T e m m u z ' ,   ' A u s t o s ' ,   ' E y l ü l ' ,   ' E k i m ' ,   ' K a s 1m ' ,   ' A r a l 1k ' ] ;  
  
 / * *  
   *   A n   A r r a y   o f   a b b r e v i a t e d   m o n t h   n a m e s   s t a r t i n g   w i t h   J a n .  
   *    
   *   @ e x a m p l e   a b b r M o n t h N a m e s [ 0 ]  
   *   @ r e s u l t   ' J a n '  
   *  
   *   @ n a m e   m o n t h N a m e s  
   *   @ t y p e   A r r a y  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   * /  
 D a t e . a b b r M o n t h N a m e s   =   [ ' O c ' ,   ' ^u b ' ,   ' M a r ' ,   ' N i s ' ,   ' M a y ' ,   ' H a z ' ,   ' T e m ' ,   ' A u ' ,   ' E y ' ,   ' E k ' ,   ' K a s ' ,   ' A r a ' ] ;  
  
 / * *  
   *   T h e   f i r s t   d a y   o f   t h e   w e e k   f o r   t h i s   l o c a l e .  
   *  
   *   @ n a m e   f i r s t D a y O f W e e k  
   *   @ t y p e   N u m b e r  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   *   @ a u t h o r   K e l v i n   L u c k  
   * /  
 D a t e . f i r s t D a y O f W e e k   =   1 ;  
  
 / * *  
   *   T h e   f o r m a t   t h a t   s t r i n g   d a t e s   s h o u l d   b e   r e p r e s e n t e d   a s   ( e . g .   ' d d / m m / y y y y '   f o r   U K ,   ' m m / d d / y y y y '   f o r   U S ,   ' y y y y - m m - d d '   f o r   U n i c o d e   e t c ) .  
   *  
   *   @ n a m e   f o r m a t  
   *   @ t y p e   S t r i n g  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   *   @ a u t h o r   K e l v i n   L u c k  
   * /  
 D a t e . f o r m a t   =   ' m m / d d / y y y y ' ;  
 / / D a t e . f o r m a t   =   ' m m / d d / y y y y ' ;  
 / / D a t e . f o r m a t   =   ' y y y y - m m - d d ' ;  
 / / D a t e . f o r m a t   =   ' d d   m m m   y y ' ;  
  
 / * *  
   *   T h e   f i r s t   t w o   n u m b e r s   i n   t h e   c e n t u r y   t o   b e   u s e d   w h e n   d e c o d i n g   a   t w o   d i g i t   y e a r .   S i n c e   a   t w o   d i g i t   y e a r   i s   a m b i g u o u s   ( a n d   d a t e . s e t Y e a r  
   *   o n l y   w o r k s   w i t h   n u m b e r s   <   9 9   a n d   s o   d o e s n ' t   a l l o w   y o u   t o   s e t   y e a r s   a f t e r   2 0 0 0 )   w e   n e e d   t o   u s e   t h i s   t o   d i s a m b i g u a t e   t h e   t w o   d i g i t   y e a r   c o d e s .  
   *  
   *   @ n a m e   f o r m a t  
   *   @ t y p e   S t r i n g  
   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
   *   @ a u t h o r   K e l v i n   L u c k  
   * /  
 D a t e . f u l l Y e a r S t a r t   =   ' 2 0 ' ;  
  
 ( f u n c t i o n ( )   {  
  
 	 / * *  
 	   *   A d d s   a   g i v e n   m e t h o d   u n d e r   t h e   g i v e n   n a m e    
 	   *   t o   t h e   D a t e   p r o t o t y p e   i f   i t   d o e s n ' t  
 	   *   c u r r e n t l y   e x i s t .  
 	   *  
 	   *   @ p r i v a t e  
 	   * /  
 	 f u n c t i o n   a d d ( n a m e ,   m e t h o d )   {  
 	 	 i f (   ! D a t e . p r o t o t y p e [ n a m e ]   )   {  
 	 	 	 D a t e . p r o t o t y p e [ n a m e ]   =   m e t h o d ;  
 	 	 }  
 	 } ;  
 	  
 	 / * *  
 	   *   C h e c k s   i f   t h e   y e a r   i s   a   l e a p   y e a r .  
 	   *  
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . i s L e a p Y e a r ( ) ;  
 	   *   @ r e s u l t   t r u e  
 	   *  
 	   *   @ n a m e   i s L e a p Y e a r  
 	   *   @ t y p e   B o o l e a n  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " i s L e a p Y e a r " ,   f u n c t i o n ( )   {  
 	 	 v a r   y   =   t h i s . g e t F u l l Y e a r ( ) ;  
 	 	 r e t u r n   ( y % 4 = = 0   & &   y % 1 0 0 ! = 0 )   | |   y % 4 0 0 = = 0 ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   C h e c k s   i f   t h e   d a y   i s   a   w e e k e n d   d a y   ( S a t   o r   S u n ) .  
 	   *  
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . i s W e e k e n d ( ) ;  
 	   *   @ r e s u l t   f a l s e  
 	   *  
 	   *   @ n a m e   i s W e e k e n d  
 	   *   @ t y p e   B o o l e a n  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " i s W e e k e n d " ,   f u n c t i o n ( )   {  
 	 	 r e t u r n   t h i s . g e t D a y ( ) = = 0   | |   t h i s . g e t D a y ( ) = = 6 ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   C h e c k   i f   t h e   d a y   i s   a   d a y   o f   t h e   w e e k   ( M o n - F r i )  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . i s W e e k D a y ( ) ;  
 	   *   @ r e s u l t   f a l s e  
 	   *    
 	   *   @ n a m e   i s W e e k D a y  
 	   *   @ t y p e   B o o l e a n  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " i s W e e k D a y " ,   f u n c t i o n ( )   {  
 	 	 r e t u r n   ! t h i s . i s W e e k e n d ( ) ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   G e t s   t h e   n u m b e r   o f   d a y s   i n   t h e   m o n t h .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t D a y s I n M o n t h ( ) ;  
 	   *   @ r e s u l t   3 1  
 	   *    
 	   *   @ n a m e   g e t D a y s I n M o n t h  
 	   *   @ t y p e   N u m b e r  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " g e t D a y s I n M o n t h " ,   f u n c t i o n ( )   {  
 	 	 r e t u r n   [ 3 1 , ( t h i s . i s L e a p Y e a r ( )   ?   2 9 : 2 8 ) , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 ] [ t h i s . g e t M o n t h ( ) ] ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   G e t s   t h e   n a m e   o f   t h e   d a y .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t D a y N a m e ( ) ;  
 	   *   @ r e s u l t   ' C u m a r t e s i '  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t D a y N a m e ( t r u e ) ;  
 	   *   @ r e s u l t   ' S a t '  
 	   *    
 	   *   @ p a r a m   a b b r e v i a t e d   B o o l e a n   W h e n   s e t   t o   t r u e   t h e   n a m e   w i l l   b e   a b b r e v i a t e d .  
 	   *   @ n a m e   g e t D a y N a m e  
 	   *   @ t y p e   S t r i n g  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " g e t D a y N a m e " ,   f u n c t i o n ( a b b r e v i a t e d )   {  
 	 	 r e t u r n   a b b r e v i a t e d   ?   D a t e . a b b r D a y N a m e s [ t h i s . g e t D a y ( ) ]   :   D a t e . d a y N a m e s [ t h i s . g e t D a y ( ) ] ;  
 	 } ) ;  
  
 	 / * *  
 	   *   G e t s   t h e   n a m e   o f   t h e   m o n t h .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t M o n t h N a m e ( ) ;  
 	   *   @ r e s u l t   ' J a n u r a r y '  
 	   *  
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t M o n t h N a m e ( t r u e ) ;  
 	   *   @ r e s u l t   ' J a n '  
 	   *    
 	   *   @ p a r a m   a b b r e v i a t e d   B o o l e a n   W h e n   s e t   t o   t r u e   t h e   n a m e   w i l l   b e   a b b r e v i a t e d .  
 	   *   @ n a m e   g e t D a y N a m e  
 	   *   @ t y p e   S t r i n g  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " g e t M o n t h N a m e " ,   f u n c t i o n ( a b b r e v i a t e d )   {  
 	 	 r e t u r n   a b b r e v i a t e d   ?   D a t e . a b b r M o n t h N a m e s [ t h i s . g e t M o n t h ( ) ]   :   D a t e . m o n t h N a m e s [ t h i s . g e t M o n t h ( ) ] ;  
 	 } ) ;  
  
 	 / * *  
 	   *   G e t   t h e   n u m b e r   o f   t h e   d a y   o f   t h e   y e a r .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t D a y O f Y e a r ( ) ;  
 	   *   @ r e s u l t   1 1  
 	   *    
 	   *   @ n a m e   g e t D a y O f Y e a r  
 	   *   @ t y p e   N u m b e r  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " g e t D a y O f Y e a r " ,   f u n c t i o n ( )   {  
 	 	 v a r   t m p d t m   =   n e w   D a t e ( " 1 / 1 / "   +   t h i s . g e t F u l l Y e a r ( ) ) ;  
 	 	 r e t u r n   M a t h . f l o o r ( ( t h i s . g e t T i m e ( )   -   t m p d t m . g e t T i m e ( ) )   /   8 6 4 0 0 0 0 0 ) ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   G e t   t h e   n u m b e r   o f   t h e   w e e k   o f   t h e   y e a r .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . g e t W e e k O f Y e a r ( ) ;  
 	   *   @ r e s u l t   2  
 	   *    
 	   *   @ n a m e   g e t W e e k O f Y e a r  
 	   *   @ t y p e   N u m b e r  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " g e t W e e k O f Y e a r " ,   f u n c t i o n ( )   {  
 	 	 r e t u r n   M a t h . c e i l ( t h i s . g e t D a y O f Y e a r ( )   /   7 ) ;  
 	 } ) ;  
  
 	 / * *  
 	   *   S e t   t h e   d a y   o f   t h e   y e a r .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . s e t D a y O f Y e a r ( 1 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' T u e   J a n   0 1   2 0 0 8   0 0 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   s e t D a y O f Y e a r  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " s e t D a y O f Y e a r " ,   f u n c t i o n ( d a y )   {  
 	 	 t h i s . s e t M o n t h ( 0 ) ;  
 	 	 t h i s . s e t D a t e ( d a y ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   y e a r s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d Y e a r s ( 1 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' M o n   J a n   1 2   2 0 0 9   0 0 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d Y e a r s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d Y e a r s " ,   f u n c t i o n ( n u m )   {  
 	 	 t h i s . s e t F u l l Y e a r ( t h i s . g e t F u l l Y e a r ( )   +   n u m ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   m o n t h s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d M o n t h s ( 1 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' T u e   F e b   1 2   2 0 0 8   0 0 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d M o n t h s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d M o n t h s " ,   f u n c t i o n ( n u m )   {  
 	 	 v a r   t m p d t m   =   t h i s . g e t D a t e ( ) ;  
 	 	  
 	 	 t h i s . s e t M o n t h ( t h i s . g e t M o n t h ( )   +   n u m ) ;  
 	 	  
 	 	 i f   ( t m p d t m   >   t h i s . g e t D a t e ( ) )  
 	 	 	 t h i s . a d d D a y s ( - t h i s . g e t D a t e ( ) ) ;  
 	 	  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   d a y s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d D a y s ( 1 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S u n   J a n   1 3   2 0 0 8   0 0 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d D a y s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d D a y s " ,   f u n c t i o n ( n u m )   {  
 	 	 / / t h i s . s e t D a t e ( t h i s . g e t D a t e ( )   +   n u m ) ;  
 	 	 t h i s . s e t T i m e ( t h i s . g e t T i m e ( )   +   ( n u m * 8 6 4 0 0 0 0 0 )   ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   h o u r s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d H o u r s ( 2 4 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S u n   J a n   1 3   2 0 0 8   0 0 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d H o u r s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d H o u r s " ,   f u n c t i o n ( n u m )   {  
 	 	 t h i s . s e t H o u r s ( t h i s . g e t H o u r s ( )   +   n u m ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   m i n u t e s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d M i n u t e s ( 6 0 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S a t   J a n   1 2   2 0 0 8   0 1 : 0 0 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d M i n u t e s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d M i n u t e s " ,   f u n c t i o n ( n u m )   {  
 	 	 t h i s . s e t M i n u t e s ( t h i s . g e t M i n u t e s ( )   +   n u m ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   A d d   a   n u m b e r   o f   s e c o n d s   t o   t h e   d a t e   o b j e c t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a d d S e c o n d s ( 6 0 ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S a t   J a n   1 2   2 0 0 8   0 0 : 0 1 : 0 0 '  
 	   *    
 	   *   @ n a m e   a d d S e c o n d s  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   * /  
 	 a d d ( " a d d S e c o n d s " ,   f u n c t i o n ( n u m )   {  
 	 	 t h i s . s e t S e c o n d s ( t h i s . g e t S e c o n d s ( )   +   n u m ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   S e t s   t h e   t i m e   c o m p o n e n t   o f   t h i s   D a t e   t o   z e r o   f o r   c l e a n e r ,   e a s i e r   c o m p a r i s o n   o f   d a t e s   w h e r e   t i m e   i s   n o t   r e l e v a n t .  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( ) ;  
 	   *   d t m . z e r o T i m e ( ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S a t   J a n   1 2   2 0 0 8   0 0 : 0 1 : 0 0 '  
 	   *    
 	   *   @ n a m e   z e r o T i m e  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   *   @ a u t h o r   K e l v i n   L u c k  
 	   * /  
 	 a d d ( " z e r o T i m e " ,   f u n c t i o n ( )   {  
 	 	 t h i s . s e t M i l l i s e c o n d s ( 0 ) ;  
 	 	 t h i s . s e t S e c o n d s ( 0 ) ;  
 	 	 t h i s . s e t M i n u t e s ( 0 ) ;  
 	 	 t h i s . s e t H o u r s ( 0 ) ;  
 	 	 r e t u r n   t h i s ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   R e t u r n s   a   s t r i n g   r e p r e s e n t a t i o n   o f   t h e   d a t e   o b j e c t   a c c o r d i n g   t o   D a t e . f o r m a t .  
 	   *   ( D a t e . t o S t r i n g   M a y 1s   b e   u s e d   i n   o t h e r   p l a c e s   s o   I   p u r p o s e f u l l y   d i d n ' t   o v e r w r i t e   i t )  
 	   *    
 	   *   @ e x a m p l e   v a r   d t m   =   n e w   D a t e ( " 0 1 / 1 2 / 2 0 0 8 " ) ;  
 	   *   d t m . a s S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' 1 2 / 0 1 / 2 0 0 8 '   / /   ( w h e r e   D a t e . f o r m a t   = =   ' d d / m m / y y y y '  
 	   *    
 	   *   @ n a m e   a s S t r i n g  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   *   @ a u t h o r   K e l v i n   L u c k  
 	   * /  
 	 a d d ( " a s S t r i n g " ,   f u n c t i o n ( f o r m a t )   {  
 	 	 v a r   r   =   f o r m a t   | |   D a t e . f o r m a t ;  
 	 	 i f   ( r . s p l i t ( ' m m ' ) . l e n g t h > 1 )   {   / /   u g l y   w o r k a r o u n d   t o   m a k e   s u r e   w e   d o n ' t   r e p l a c e   t h e   m ' s   i n   e . g .   K a s 1m  
 	 	 	 r   =   r . s p l i t ( ' m m m m ' ) . j o i n ( t h i s . g e t M o n t h N a m e ( f a l s e ) )  
 	 	 	 	 . s p l i t ( ' m m m ' ) . j o i n ( t h i s . g e t M o n t h N a m e ( t r u e ) )  
 	 	 	 	 . s p l i t ( ' m m ' ) . j o i n ( _ z e r o P a d ( t h i s . g e t M o n t h ( ) + 1 ) )  
 	 	 }   e l s e   {  
 	 	 	 r   =   r . s p l i t ( ' m ' ) . j o i n ( t h i s . g e t M o n t h ( ) + 1 ) ;  
 	 	 }  
 	 	 r   =   r . s p l i t ( ' y y y y ' ) . j o i n ( t h i s . g e t F u l l Y e a r ( ) )  
 	 	 	 . s p l i t ( ' y y ' ) . j o i n ( ( t h i s . g e t F u l l Y e a r ( )   +   ' ' ) . s u b s t r i n g ( 2 ) )  
 	 	 	 . s p l i t ( ' d d ' ) . j o i n ( _ z e r o P a d ( t h i s . g e t D a t e ( ) ) )  
 	 	 	 . s p l i t ( ' d ' ) . j o i n ( t h i s . g e t D a t e ( ) ) ;  
 	 	 r e t u r n   r ;  
 	 } ) ;  
 	  
 	 / * *  
 	   *   R e t u r n s   a   n e w   d a t e   o b j e c t   c r e a t e d   f r o m   t h e   p a s s e d   S t r i n g   a c c o r d i n g   t o   D a t e . f o r m a t   o r   f a l s e   i f   t h e   a t t e m p t   t o   d o   t h i s   r e s u l t s   i n   a n   i n v a l i d   d a t e   o b j e c t  
 	   *   ( W e   c a n ' t   s i m p l e   u s e   D a t e . p a r s e   a s   i t ' s   n o t   a w a r e   o f   l o c a l e   a n d   I   c h o s e   n o t   t o   o v e r w r i t e   i t   i n c a s e   i t ' s   f u n c t i o n a l i t y   i s   b e i n g   r e l i e d   o n   e l s e w h e r e )  
 	   *  
 	   *   @ e x a m p l e   v a r   d t m   =   D a t e . f r o m S t r i n g ( " 1 2 / 0 1 / 2 0 0 8 " ) ;  
 	   *   d t m . t o S t r i n g ( ) ;  
 	   *   @ r e s u l t   ' S a t   J a n   1 2   2 0 0 8   0 0 : 0 0 : 0 0 '   / /   ( w h e r e   D a t e . f o r m a t   = =   ' d d / m m / y y y y '  
 	   *    
 	   *   @ n a m e   f r o m S t r i n g  
 	   *   @ t y p e   D a t e  
 	   *   @ c a t   P l u g i n s / M e t h o d s / D a t e  
 	   *   @ a u t h o r   K e l v i n   L u c k  
 	   * /  
 	 D a t e . f r o m S t r i n g   =   f u n c t i o n ( s )  
 	 {  
 	 	 v a r   f   =   D a t e . f o r m a t ;  
 	 	  
 	 	 v a r   d   =   n e w   D a t e ( ' 0 1 / 0 1 / 1 9 7 0 ' ) ;  
 	 	  
 	 	 i f   ( s   = =   ' ' )   r e t u r n   d ;  
  
 	 	 s   =   s . t o L o w e r C a s e ( ) ;  
 	 	 v a r   m a t c h e r   =   ' ' ;  
 	 	 v a r   o r d e r   =   [ ] ;  
 	 	 v a r   r   =   / ( d d ? d ? | m m ? m ? | y y ? y y ? ) + ( [ ^ ( m | d | y ) ] ) ? / g ;  
 	 	 v a r   r e s u l t s ;  
 	 	 w h i l e   ( ( r e s u l t s   =   r . e x e c ( f ) )   ! =   n u l l )  
 	 	 {  
 	 	 	 s w i t c h   ( r e s u l t s [ 1 ] )   {  
 	 	 	 	 c a s e   ' d ' :  
 	 	 	 	 c a s e   ' d d ' :  
 	 	 	 	 c a s e   ' m ' :  
 	 	 	 	 c a s e   ' m m ' :  
 	 	 	 	 c a s e   ' y y ' :  
 	 	 	 	 c a s e   ' y y y y ' :  
 	 	 	 	 	 m a t c h e r   + =   ' ( \ \ d + \ \ d ? \ \ d ? \ \ d ? ) + ' ;  
 	 	 	 	 	 o r d e r . p u s h ( r e s u l t s [ 1 ] . s u b s t r ( 0 ,   1 ) ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   ' m m m ' :  
 	 	 	 	 	 m a t c h e r   + =   ' ( [ a - z ] { 3 } ) ' ;  
 	 	 	 	 	 o r d e r . p u s h ( ' M ' ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 }  
 	 	 	 i f   ( r e s u l t s [ 2 ] )   {  
 	 	 	 	 m a t c h e r   + =   r e s u l t s [ 2 ] ;  
 	 	 	 }  
 	 	 	  
 	 	 }  
 	 	 v a r   d m   =   n e w   R e g E x p ( m a t c h e r ) ;  
 	 	 v a r   r e s u l t   =   s . m a t c h ( d m ) ;  
 	 	 f o r   ( v a r   i = 0 ;   i < o r d e r . l e n g t h ;   i + + )   {  
 	 	 	 v a r   r e s   =   r e s u l t [ i + 1 ] ;  
 	 	 	 s w i t c h ( o r d e r [ i ] )   {  
 	 	 	 	 c a s e   ' d ' :  
 	 	 	 	 	 d . s e t D a t e ( r e s ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   ' m ' :  
 	 	 	 	 	 d . s e t M o n t h ( N u m b e r ( r e s ) - 1 ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   ' M ' :  
 	 	 	 	 	 f o r   ( v a r   j = 0 ;   j < D a t e . a b b r M o n t h N a m e s . l e n g t h ;   j + + )   {  
 	 	 	 	 	 	 i f   ( D a t e . a b b r M o n t h N a m e s [ j ] . t o L o w e r C a s e ( )   = =   r e s )   b r e a k ;  
 	 	 	 	 	 }  
 	 	 	 	 	 d . s e t M o n t h ( j ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   ' y ' :  
 	 	 	 	 	 d . s e t Y e a r ( r e s ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 }  
 	 	 }  
  
 	 	 r e t u r n   d ;  
 	 } ;  
 	  
 	 / /   u t i l i t y   m e t h o d  
 	 v a r   _ z e r o P a d   =   f u n c t i o n ( n u m )   {  
 	 	 v a r   s   =   ' 0 ' + n u m ;  
 	 	 r e t u r n   s . s u b s t r i n g ( s . l e n g t h - 2 )  
 	 	 / / r e t u r n   ( ' 0 ' + n u m ) . s u b s t r i n g ( - 2 ) ;   / /   d o e s n ' t   w o r k   o n   I E   : (  
 	 } ;  
 	  
 } ) ( ) ; 
