+
    lht                     L   R t ^ RIt^ RIt^ RIHtHt ^ RIt^ RIH	t	 . RNRNRNRNRNR	NR
NRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNRNR NR!NR"NR#NR$NR%NR&NR'NR(NR)NR*NR+NR,NR-NR.NR/NR0Nt
]t ! R1 R]]4      t ! R2 R]4      tR3 t] ! R4 R]4      4       t] ! R5 R]4      4       t. RYOt ! R6 R74      t ! R8 R94      t]! R:4      t]! R;4      t]! R<4      t]! R=4      tR> tR? tR@ tRA tRB tRC tRD t RE t! ! RF R]"4      t# ! RG R]#4      t$ ! RH R]#4      t% ! RI RJ4      t&RK t' ! RL R]$4      t( ! RM R]%4      t) ! RN RO]$4      t* ! RP RQ](]*4      t+]$! 4       t,],PZ                  t.RR t/],P`                  t1],Pd                  t2],Pf                  t4],Pj                  t6],Pn                  t7],Pp                  t9],Pt                  t;],Px                  t=^t>^t?]>]?3RS lt@]>]?3RT ltARUtB]P                  ! ]B^^4      P                  4       tERV tFRZRW ltG]HRX8X  d
   ]G! 4        R# R# )[a$  Calendar printing functions

Note when comparing these calendars to the ones printed by cal(1): By
default, these calendars have Monday as the first day of the week, and
Sunday as the last (the European convention). Use setfirstweekday() to
set the first day of the week (0=Monday, 6=Sunday).N)IntEnumglobal_enum)repeatIllegalMonthErrorIllegalWeekdayErrorsetfirstweekdayfirstweekdayisleapleapdaysweekday
monthrangemonthcalendarprmonthmonthprcalcalendartimegm
month_name
month_abbrday_nameday_abbrCalendarTextCalendarHTMLCalendarLocaleTextCalendarLocaleHTMLCalendar
weekheaderDayMonthJANUARYFEBRUARYMARCHAPRILMAYJUNEJULYAUGUST	SEPTEMBEROCTOBERNOVEMBERDECEMBERMONDAYTUESDAY	WEDNESDAYTHURSDAYFRIDAYSATURDAYSUNDAYc                   ,   a  ] tR t^ t o R tR tRtV tR# )r   c                    Wn         R # Nr   )selfr   s   &&lib/python3.14/calendar.py__init__IllegalMonthError.__init__!   s    
    c                (    R V P                   ,          # )z!bad month number %r; must be 1-12r5   r6   s   &r7   __str__IllegalMonthError.__str__#   s    2TZZ??r:   r5   N__name__
__module____qualname____firstlineno__r8   r=   __static_attributes____classdictcell____classdict__s   @r7   r   r       s     @ @r:   c                   ,   a  ] tR t^'t o R tR tRtV tR# )r   c                    Wn         R # r4   r   )r6   r   s   &&r7   r8   IllegalWeekdayError.__init__(   s    r:   c                (    R V P                   ,          # )z7bad weekday number %r; must be 0 (Monday) to 6 (Sunday)rJ   r<   s   &r7   r=   IllegalWeekdayError.__str__*   s    H4<<WWr:   rJ   Nr?   rF   s   @r7   r   r   '   s     X Xr:   c                     V R	9   d=   ^ RI pVP                  RV  RV P                  4        R2\        ^R7       V R 8X  d   ^# ^# \	        R\
         RV  R24      h)
JanuaryNzThe 'z ' attribute is deprecated, use 'z	' instead)
stacklevelzmodule 'z' has no attribute '')rO   February)warningswarnupperDeprecationWarningAttributeErrorr@   )namerS   s   & r7   __getattr__rY   .   sf    &&dV#CDJJL>QZ[(Q 	 	89
8H:-A$qI
JJr:   c                   F    ] tR t^<t^t^t^t^t^t^t	^t
^t^	t^
t^t^tRtR# )r    N)r@   rA   rB   rC   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   rD   r[   r:   r7   r   r   <   s>    GHEE
CDDFIGHHr:   c                   2    ] tR t^Mt^ t^t^t^t^t^t	^t
RtR# )r   r[   N)r@   rA   rB   rC   r+   r,   r-   r.   r/   r0   r1   rD   r[   r:   r7   r   r   M   s%    FGIHFHFr:   c                      a ] tR t^`t o]! ^4       U u. uF,  p \
        P                  ! RV ^,           ^4      P                  NK.  	  up t]P                  ^ R 4       R t
R tR tRtVtR# u up i )_localized_month  c                    R # ) r[   )xs   &r7   <lambda>_localized_month.<lambda>c   s    r:   c                    Wn         R # r4   formatr6   rg   s   &&r7   r8   _localized_month.__init__e       r:   c                    V P                   V,          p\        V\        4      '       d"   V Uu. uF  q3! V P                  4      NK  	  up# V! V P                  4      # u upi r4   )_months
isinstanceslicerg   r6   ifuncsfs   &&  r7   __getitem___localized_month.__getitem__h   sM    Qa,12EqAdkkNE22%% 3   Ac                    ^# )   r[   r<   s   &r7   __len___localized_month.__len__o   s    r:   rf   N)r@   rA   rB   rC   rangedatetimedatestrftimerl   insertr8   rs   rx   rD   rE   rp   rG   s   0@r7   r^   r^   `   s\     =B2YGYx}}T1Q3*33YGGNN1l#&  Hs   2A+r^   c            	          a ] tR t^st o]! ^4       U u. uF,  p \
        P                  ! R^V ^,           4      P                  NK.  	  up tR t	R t
R tRtVtR# u up i )_localized_dayr_   c                    Wn         R # r4   rf   rh   s   &&r7   r8   _localized_day.__init__x   rj   r:   c                    V P                   V,          p\        V\        4      '       d"   V Uu. uF  q3! V P                  4      NK  	  up# V! V P                  4      # u upi r4   )_daysrm   rn   rg   ro   s   &&  r7   rs   _localized_day.__getitem__{   sM    

1a,12EqAdkkNE22%% 3ru   c                    ^#    r[   r<   s   &r7   rx   _localized_day.__len__   s    r:   rf   N)r@   rA   rB   rC   rz   r{   r|   r}   r   r8   rs   rx   rD   rE   r   s   0@r7   r   r   s   sQ      <A8D8aX]]4AaC(118DE&  Es   2Ar   z%Az%az%Bz%bc                j    V ^,          ^ 8H  ;'       d!    V ^d,          ^ 8g  ;'       g    V R,          ^ 8H  # )z5Return True for leap years, False for non-leap years.  r[   )years   &r7   r	   r	      s0    !8q=AAdSjAo@@qAr:   c                    V ^,          p V^,          pV^,          V ^,          ,
          V^d,          V ^d,          ,
          ,
          VR,          V R,          ,
          ,           # )z?Return number of leap years in range [y1, y2).
Assume y1 <= y2.r   r[   )y1y2s   &&r7   r
   r
      sL     !GB!GBEBEMb#gC/0BGb#g4EFFr:   c                    \         P                  T u;8:  d   \         P                  8:  g   M RV R,          ,           p \        \         P                  ! WV4      P                  4       4      # )zBReturn weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31).i  r   )r{   MINYEARMAXYEARr   r|   r   )r   r   days   &&&r7   r   r      sH    t7x'7'77dSj x}}T#.66899r:   c                 >    ^T u;8:  d   ^8:  g   M \        V 4      hR# )   N)r   r5   s   &r7   _validate_monthr      s    && r:   c                    \        V4       \        W^4      p\        V,          V\        8H  ;'       d    \	        V 4      ,           pW#3# )z`Return weekday of first day of month (0-6 ~ Mon-Sun)
and number of days (28-31) for year, month.)r   r   mdaysr    r	   )r   r   day1ndayss   &&  r7   r   r      s?     E4"D%LEX->>&,?E;r:   c                 ^    \         V,          V\        8H  ;'       d    \        V 4      ,           # r4   )r   r    r	   r   r   s   &&r7   	_monthlenr      s"    <5H,==>>r:   c                 :    V^8X  d   V ^,
          ^3# W^,
          3# )r   r[   r   s   &&r7   
_prevmonthr      s#    zAvrz1W}r:   c                 :    V^8X  d   V ^,           ^3# W^,           3# )   r[   r   s   &&r7   
_nextmonthr      s#    {Avqy1W}r:   c                      a  ] tR t^t o RtRR ltR tR t]! ]]4      t	R t
R tR tR tR	 tR
 tR tR tR tRR ltRR ltRR ltRtV tR# )r   zc
Base calendar class. This class doesn't do any formatting. It simply
provides data to subclasses.
c                    Wn         R # r4   r   r6   r   s   &&r7   r8   Calendar.__init__   s    (r:   c                (    V P                   ^,          # r   _firstweekdayr<   s   &r7   getfirstweekdayCalendar.getfirstweekday   s    !!A%%r:   c                    Wn         R # r4   r   r   s   &&r7   r   Calendar.setfirstweekday   s    )r:   c              #     "   \        V P                  V P                  ^,           4       F  pV^,          x  K  	  R# 5i)z\
Return an iterator for one week of weekday numbers starting with the
configured first one.
N)rz   r   )r6   rp   s   & r7   iterweekdaysCalendar.iterweekdays   s3     
 t(($*;*;a*?@AA#I As   <>c              #  v   "   V P                  W4       F  w  r4p\        P                  ! W4V4      x  K!  	  R# 5i)z
Return an iterator for one month. The iterator will yield datetime.date
values and will always iterate through complete weeks, so it will yield
dates outside the specified month.
N)itermonthdays3r{   r|   )r6   r   r   ymds   &&&   r7   itermonthdatesCalendar.itermonthdates   s1      **47GA!--a(( 8s   79c              #  .  "   \        W4      w  r4W0P                  ,
          ^,          p\        ^ V4       Rj  xL
  \        ^V^,           4       Rj  xL
  V P                  V,
          V,
          ^,          p\        ^ V4       Rj  xL
  R#  LV L= L
5i)zn
Like itermonthdates(), but will yield day numbers. For days outside
the specified month the day number is 0.
N)r   r   r   rz   )r6   r   r   r   r   days_before
days_afters   &&&    r7   itermonthdaysCalendar.itermonthdays   s     
 !-///14![)))EAI&&&''$.6!;
!Z((( 	*&(s3   6BBBB4BB	BBBc              #     "   \        V P                  W4      V P                  4       F  w  r4WC^,          3x  K  	  R# 5i)z
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
N)	enumerater   r   )r6   r   r   rp   r   s   &&&  r7   itermonthdays2Calendar.itermonthdays2   s7     
 d00=t?P?PQDAU(N Rs   =?c              #    "   \        W4      w  r4W0P                  ,
          ^,          pV P                  V,
          V,
          ^,          p\        W4      w  rx\        Wx4      ^,           p	\	        W,
          V	4       F	  p
WxV
3x  K  	  \	        ^V^,           4       F	  p
WV
3x  K  	  \        W4      w  rx\	        ^V^,           4       F	  p
WxV
3x  K  	  R# 5i)zy
Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
used for dates outside of datetime.date range.
N)r   r   r   r   rz   r   )r6   r   r   r   r   r   r   r   r   endr   s   &&&        r7   r   Calendar.itermonthdays3   s     
 !-///14''$.6!;
$&o!s,A'M -q%!)$Aq.  %$&q*q.)A'M *s   CCc              #     "   \        V P                  W4      4       F'  w  pw  rEpWEW`P                  V,           ^,          3x  K)  	  R# 5i)z
Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
Can be used for dates outside of datetime.date range.
N)r   r   r   )r6   r   r   rp   r   r   r   s   &&&    r7   itermonthdays4Calendar.itermonthdays4
  sE     
 &d&9&9$&FGLAya--1Q666 Hs   AA
c                    \        V P                  W4      4      p\        ^ \        V4      ^4       Uu. uF  qCWD^,            NK  	  up# u upi )z
Return a matrix (list of lists) representing a month's calendar.
Each row represents a week; week entries are datetime.date values.
)listr   rz   len)r6   r   r   datesrp   s   &&&  r7   monthdatescalendarCalendar.monthdatescalendar  sF    
 T((56',QE
A'>@'>!q1'>@@@   A	c                    \        V P                  W4      4      p\        ^ \        V4      ^4       Uu. uF  qCWD^,            NK  	  up# u upi )z
Return a matrix representing a month's calendar.
Each row represents a week; week entries are
(day number, weekday number) tuples. Day numbers outside this month
are zero.
)r   r   rz   r   r6   r   r   daysrp   s   &&&  r7   monthdays2calendarCalendar.monthdays2calendar  sF     D''45&+As4y!&<>&<a!&<>>>r   c                    \        V P                  W4      4      p\        ^ \        V4      ^4       Uu. uF  qCWD^,            NK  	  up# u upi )zp
Return a matrix representing a month's calendar.
Each row represents a week; days outside this month are zero.
)r   r   rz   r   r   s   &&&  r7   monthdayscalendarCalendar.monthdayscalendar$  sF    
 D&&t34&+As4y!&<>&<a!&<>>>r   c                    \          Uu. uF  q0P                  W4      NK  	  pp\        ^ \        V4      V4       Uu. uF  qTWUV,            NK  	  up# u upi u upi )z
Return the data for the specified year ready for formatting. The return
value is a list of month rows. Each month row contains up to width months.
Each month contains between 4 and 6 weeks and each week contains 1-7
days. Days are datetime.date objects.
)r   r   rz   r   r6   r   widthr   monthsrp   s   &&&   r7   yeardatescalendarCalendar.yeardatescalendar,  V     =BBEq))$2EB+0CK+GI+Gaq5!+GII CI
   AAc                    \          Uu. uF  q0P                  W4      NK  	  pp\        ^ \        V4      V4       Uu. uF  qTWUV,            NK  	  up# u upi u upi )z
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are
(day number, weekday number) tuples. Day numbers outside this month are
zero.
)r   r   rz   r   r   s   &&&   r7   yeardays2calendarCalendar.yeardays2calendar6  r   r   c                    \          Uu. uF  q0P                  W4      NK  	  pp\        ^ \        V4      V4       Uu. uF  qTWUV,            NK  	  up# u upi u upi )z
Return the data for the specified year ready for formatting (similar to
yeardatescalendar()). Entries in the week lists are day numbers.
Day numbers outside this month are zero.
)r   r   rz   r   r   s   &&&   r7   yeardayscalendarCalendar.yeardayscalendar@  sV     <AA5a((15A+0CK+GI+Gaq5!+GII BIr   )r   r   N)       )r@   rA   rB   rC   __doc__r8   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   rD   rE   rF   s   @r7   r   r      sm     
)&* O_=L)
)$7A??JJJ Jr:   c                   t   a  ] tR tRt o RtR tR tR tR tR t	RR lt
RR	 ltRR
 ltRR ltRR ltRtV tR# )r   iJ  zf
Subclass of Calendar that outputs a calendar as a simple plain text
similar to the UNIX program cal.
c                >    \        V P                  W4      RR7       R# )z#
Print a single week (no newline).
ra   r   N)print
formatweekr6   theweekr   s   &&&r7   prweekTextCalendar.prweekP  s     	doog-26r:   c                J    V^ 8X  d   RpM	RV,          pVP                  V4      # )z
Returns a formatted day.
ra   z%2icenter)r6   r   r   r   ss   &&&& r7   	formatdayTextCalendar.formatdayV  s'     !8AAxxr:   c                >   a a RP                  V V3R lV 4       4      # )1
Returns a single week in a string (no newline).
 c              3   L   <"   T F  w  rSP                  WS4      x  K  	  R # 5ir4   r   ).0r   wdr6   r   s   &  r7   	<genexpr>*TextCalendar.formatweek.<locals>.<genexpr>d  s!     LG!qe44G   !$joinr   s   f&fr7   r   TextCalendar.formatweek`  s     xxLGLLLr:   c                ^    V^	8  d   \         pM\        pW1,          RV P                  V4      # )z$
Returns a formatted week day name.
N)r   r   r   )r6   r   r   namess   &&& r7   formatweekdayTextCalendar.formatweekdayf  s/     A:EEz&5!((//r:   c                Z   a a RP                  V V3R lS P                  4        4       4      # )z
Return a header for a week.
r   c              3   H   <"   T F  pSP                  VS4      x  K  	  R # 5ir4   r	  )r   rp   r6   r   s   & r7   r  0TextCalendar.formatweekheader.<locals>.<genexpr>t  s#     R>Q**1e44>Qs   "r  r   )r6   r   s   ffr7   formatweekheaderTextCalendar.formatweekheaderp  s#     xxRd>O>O>QRRRr:   c                v    \        V4       \        V,          pV'       d
   V: RV: 2pVP                  V4      # )z 
Return a formatted month name.
r   )r   r   r   )r6   theyearthemonthr   withyearr   s   &&&&& r7   formatmonthnameTextCalendar.formatmonthnamev  s1     	!x g&Axxr:   c                @    \        V P                  WW44      RR7       R# )z
Print a month's calendar.
ra   r   N)r   formatmonth)r6   r  r  wls   &&&&&r7   r   TextCalendar.prmonth  s     	dw!7R@r:   c                   \        ^V4      p\        ^V4      pV P                  W^V^,           ,          ^,
          4      pVP                  4       pVRV,          ,          pWPP                  V4      P                  4       ,          pVRV,          ,          pV P	                  W4       F8  pWPP                  Wc4      P                  4       ,          pVRV,          ,          pK:  	  V# )0
Return a month's calendar string (multi-line).

)maxr  rstripr  r   r   )r6   r  r  r  r  r   weeks   &&&&&  r7   r  TextCalendar.formatmonth  s     1I1I  AQK!ODHHJ	TAX	""1%,,..	TAX++G>D)0022AMA ? r:   c           	       a aaa \        ^V4      p\        ^V4      p\        ^V4      pV^,           ^,          ^,
          o. pVP                  pV! \        S4      P                  SV,          WE^,
          ,          ,           4      P	                  4       4       V! RV,          4       S P                  V4      o\        S P                  SV4      4       EFp  w  r\        WX,          ^,           \        WX^,           ,          ^,           ^4      4      p
V! RV,          4       VV V3R lV
 4       pV! \        VSV4      P	                  4       4       V! RV,          4       V3R lV
 4       pV! \        VSV4      P	                  4       4       V! RV,          4       \        R V	 4       4      p\        V4       F  p. pV	 FN  pV\        V4      8  d   VP                  R4       K&  VP                  S P                  VV,          V4      4       KP  	  V! \        VSV4      P	                  4       4       V! RV,          4       K  	  EKs  	  RP                  V4      # )3
Returns a year's calendar as a multi-line string.
r  c              3   L   <"   T F  pSP                  SVSR 4      x  K  	  R# 5iFNr  r   kcolwidthr6   r  s   & r7   r  *TextCalendar.formatyear.<locals>.<genexpr>  ,      &$ ))'1hFF$r  c              3   (   <"   T F  pSx  K	  	  R # 5ir4   r[   r   r*  headers   & r7   r  r,         .v!vv   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir4   r   r   cals   & r7   r  r,         1ScSS   ra   )r   appendreprr   r!  r  r   r   rz   minformatstringr   r   r  )r6   r  r  r  cr   varp   rowr   r  headersheightjweeksr6  r+  r0  s   ff&&&&           @@r7   
formatyearTextCalendar.formatyear  s    1I1I1IEQ;?HH	$w-

xz!qS'1
2
9
9
;<	$q&	&&q)!$"8"8!"DEHQ13q5#a1gai"45Fd1fI&$&El5(A.5578d1fI.v.Gl7Ha0779:d1fI 1S11F6]CCH}R(T__SVQ%?@	 
 ,uh299;<$( # F. wwqzr:   c           	     B    \        V P                  WW4V4      RR7       R# )zPrint a year's calendar.ra   r   N)r   rE  )r6   r  r  r  r=  r   s   &&&&&&r7   pryearTextCalendar.pryear  s    doog!2;r:   r[   NTr   r      r      r   )r   r   rN  r   )r@   rA   rB   rC   r   r   r   r   r	  r  r  r   r  rE  rH  rD   rE   rF   s   @r7   r   r   J  sE     
7M0S	A $L< <r:   c                      a  ] tR tRt o Rt. ROt]tRtRtRt	Rt
RtR tR tR tR	 tRR
 ltRR ltRR ltRR ltRtV tR# )r   i  z,
This calendar returns complete HTML pages.
nodayr   r   c                n    V^ 8X  d   RV P                   ,          # RV P                  V,          V3,          # )z
Return a day as a table cell.
z<td class="%s">&nbsp;</td>z<td class="%s">%d</td>)cssclass_noday
cssclasses)r6   r   r   s   &&&r7   r   HTMLCalendar.formatday  s5     !8/$2E2EEE+tw/G.MMMr:   c                L   a  RP                  V 3R lV 4       4      pRV,          # )z(
Return a complete week as a table row.
ra   c              3   J   <"   T F  w  rSP                  W4      x  K  	  R # 5ir4   r   )r   r   r   r6   s   &  r7   r  *HTMLCalendar.formatweek.<locals>.<genexpr>  s     AgqDNN1))s    #<tr>%s</tr>r  )r6   r   r   s   f& r7   r   HTMLCalendar.formatweek  s$     GGAAAq  r:   c                P    RV P                   V,          : R\        V,          : R2# )z*
Return a weekday name as a table header.
z<th class="">z</th>)cssclasses_weekday_headr   )r6   r   s   &&r7   r	  HTMLCalendar.formatweekday  s'    
 ((--x}}> 	>r:   c                h   a  RP                  V 3R lS P                  4        4       4      pRV,          # )z,
Return a header for a week as a table row.
ra   c              3   F   <"   T F  pSP                  V4      x  K  	  R # 5ir4   r  )r   rp   r6   s   & r7   r  0HTMLCalendar.formatweekheader.<locals>.<genexpr>  s!     G3FaD&&q))3Fs   !rX  r  )r6   r   s   f r7   r  HTMLCalendar.formatweekheader  s-     GGG43D3D3FGGq  r:   c                    \        V4       V'       d   \        V,          : RV: 2pMR\        V,          ,          pRV P                  : RV: R2# )z%
Return a month name as a table row.
r   z%sz<tr><th colspan="7" class="r[  z
</th></tr>)r   r   cssclass_month_head)r6   r  r  r  r   s   &&&& r7   r  HTMLCalendar.formatmonthname  sF     	!%h//9Az(++A$$a) 	)r:   c                   . pVP                   pV! RV P                  ,          4       V! R4       V! V P                  WVR7      4       V! R4       V! V P                  4       4       V! R4       V P	                  W4       F"  pV! V P                  V4      4       V! R4       K$  	  V! R4       V! R4       RP                  V4      # )z&
Return a formatted month as a table.
=<table border="0" cellpadding="0" cellspacing="0" class="%s">r  r  </table>ra   )r9  cssclass_monthr  r  r   r   r  )r6   r  r  r  r>  r?  r"  s   &&&&   r7   r  HTMLCalendar.formatmonth  s     HH	
I! 	"	$	$

w8

DE	$	$


!"	$++G>Ddood#$dG ? 	
*	$wwqzr:   c           
        . pVP                   p\        V^4      pV! RV P                  ,          4       V! R4       V! RW P                  V3,          4       \	        \
        \
        ^,           V4       Fa  p\	        V\        WR,           ^4      4      pV! R4       V F,  pV! R4       V! V P                  WRR7      4       V! R4       K.  	  V! R	4       Kc  	  V! R
4       RP                  V4      # )z/
Return a formatted year as a table of tables.
rf  r  z,<tr><th colspan="%d" class="%s">%s</th></tr>z<tr>z<td>Frg  z</td>z</tr>rh  ra   )	r9  r   cssclass_yearcssclass_year_headrz   r   r;  r  r  )r6   r  r   r>  r?  rp   r   r   s   &&&     r7   rE  HTMLCalendar.formatyear  s     HHE1	
I


 		$	
8**G<5 5 	6w
E2A1c!'2./FfI&	$""7">?'
  gJ 3 	
*wwqzr:   Nc                   Vf   \         P                  ! 4       p. pVP                  pV! RV,          4       V! R4       V! R4       V! R4       V! RV,          4       Ve   V! RV,          4       V! RV,          4       V! R4       V! R	4       V! V P                  W4      4       V! R
4       V! R4       RP	                  V4      P                  VR4      # )z2
Return a formatted year as a complete HTML page.
z$<?xml version="1.0" encoding="%s"?>
zn<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
z<html>
z<head>
zC<meta http-equiv="Content-Type" content="text/html; charset=%s" />
z4<link rel="stylesheet" type="text/css" href="%s" />
z<title>Calendar for %d</title>
z</head>
z<body>
z</body>
z</html>
ra   xmlcharrefreplace)sysgetdefaultencodingr9  rE  r  encode)r6   r  r   cssencodingr>  r?  s   &&&&&  r7   formatyearpageHTMLCalendar.formatyearpage3  s     --/HHH	
1H
<=	
{|	*	*	
PS[
[\?EKL	
,w
67	+	*	$//'
)*	+	+wwqz  +>??r:   r[   )montuewedthufrisatsunrJ  r   )r   calendar.cssN)r@   rA   rB   rC   r   rS  r\  rR  rc  ri  rm  rl  r   r   r	  r  r  r  rE  rv  rD   rE   rF   s   @r7   r   r     so     
 CJ ) N " N   MN!>!
)(0@ @r:   c                   2   a  ] tR tRt o R tR tR tRtV tR# )different_localeiK  c                     Wn         R V n        R # r4   locale	oldlocale)r6   r  s   &&r7   r8   different_locale.__init__L  s    r:   c                    \         P                  ! \         P                  R 4      V n        \         P                  ! \         P                  V P                  4       R # r4   )_locale	setlocaleLC_TIMEr  r  r<   s   &r7   	__enter__different_locale.__enter__P  s2     **7??DA'//4;;7r:   c                d    \         P                  ! \         P                  V P                  4       R # r4   )r  r  r  r  )r6   argss   &*r7   __exit__different_locale.__exit__T  s    '//4>>:r:   r  N)	r@   rA   rB   rC   r8   r  r  rD   rE   rF   s   @r7   r  r  K  s     8; ;r:   r  c                     \         P                  ! \         P                  R 4      p V R8X  dD   \        R4      ;_uu_ 4        \         P                  ! \         P                  R 4      p R R R 4       V # V #   + '       g   i     T # ; i)NCra   )r  r  r  r  r  s    r7   _get_default_localer  X  sb    w5F}b!! &&w=F " M6M	 "! Ms    &A22B	c                   P   a a ] tR tRt oRtRR ltV 3R ltRV 3R lltRtVt	V ;t
# )	r   ib  |
This class can be passed a locale name in the constructor and will return
month and weekday names in the specified locale.
c                X    \         P                  W4       Vf   \        4       pW n        R # r4   )r   r8   r  r  r6   r   r  s   &&&r7   r8   LocaleTextCalendar.__init__h  "    d1>(*Fr:   c                   < \        V P                  4      ;_uu_ 4        \        SV `  W4      uuR R R 4       #   + '       g   i     R # ; ir4   r  r  superr	  )r6   r   r   	__class__s   &&&r7   r	   LocaleTextCalendar.formatweekdayn  s.    dkk**7(4 +***	   9A
	c                   < \        V P                  4      ;_uu_ 4        \        SV `  WW44      uuR R R 4       #   + '       g   i     R # ; ir4   r  r  r  r  )r6   r  r  r   r  r  s   &&&&&r7   r  "LocaleTextCalendar.formatmonthnamer  s0    dkk**7*7eN +***	   :A	r  r   NrJ  r@   rA   rB   rC   r   r8   r	  r  rD   rE   __classcell__r  rG   s   @@r7   r   r   b  s      
5O Or:   c                   P   a a ] tR tRt oRtRR ltV 3R ltRV 3R lltRtVt	V ;t
# )	r   iw  r  c                X    \         P                  W4       Vf   \        4       pW n        R # r4   )r   r8   r  r  r  s   &&&r7   r8   LocaleHTMLCalendar.__init__|  r  r:   c                   < \        V P                  4      ;_uu_ 4        \        SV `  V4      uuR R R 4       #   + '       g   i     R # ; ir4   r  )r6   r   r  s   &&r7   r	   LocaleHTMLCalendar.formatweekday  s.    dkk**7(- +***r  c                   < \        V P                  4      ;_uu_ 4        \        SV `  WV4      uuR R R 4       #   + '       g   i     R # ; ir4   r  )r6   r  r  r  r  s   &&&&r7   r  "LocaleHTMLCalendar.formatmonthname  s0    dkk**7*7hG +***r  r  r  rJ  r  r  s   @@r7   r   r   w  s      .H Hr:   c                   X   a a ] tR tRt oR	V 3R lltRR/R ltR
R ltRR ltRtVt	V ;t
# )_CLIDemoCalendari  Nc                4   < \         SV `  ! V/ VB  Wn        R # r4   r  r8   highlight_dayr6   r  r  kwargsr  s   &&*,r7   r8   _CLIDemoCalendar.__init__      $)&)*r:   r  c                  a aaaa S'       d5   ^ RI Hp V! 4       pVP                   VP                   2oVP                  oMR;ooRP                  VVVV V3R lV 4       4      # )r   )
get_colorsra   r   c              3      <"   T F8  w  rVS8X  d   S SP                  WS4       S 2MSP                  WS4      x  K:  	  R # 5ir4   r   )r   r   r   	highlightr  resetr6   r   s   &  r7   r  ._CLIDemoCalendar.formatweek.<locals>.<genexpr>  sT      
 # % +dnnQE:;E7C^^A512 #s   A A)	_colorizer  BLACKBACKGROUND_YELLOWRESETr  )r6   r   r   r  r  ansir  r  s   f&fd  @@r7   r   _CLIDemoCalendar.formatweek  sc     ,<D::,t'='=&>?IJJE ""Ixx 
 
 #
 
 	
r:   c                   V P                   '       dN   V P                   P                  V8X  d3   V P                   P                  V8X  d   V P                   P                  pMRp\	        ^V4      p\	        ^V4      pV P                  W^V^,           ,          ^,
          4      pVP                  4       pVRV,          ,          pW`P                  V4      P                  4       ,          pVRV,          ,          pV P                  W4       F:  pW`P                  WsVR7      P                  4       ,          pVRV,          ,          pK<  	  V# )r  Nr  r  )
r  r   r   r   r   r  r!  r  r   r   )r6   r  r  r  r  r  r   r"  s   &&&&&   r7   r  _CLIDemoCalendar.formatmonth  s
   
 ""''72""((H4 ..22M M1I1I  AQK!ODHHJ	TAX	""1%,,..	TAX++G>DFMMOOAMA ? r:   c                  a aaa \        ^V4      p\        ^V4      p\        ^V4      pV^,           ^,          ^,
          o. pVP                  pV! \        S4      P                  SV,          WE^,
          ,          ,           4      P	                  4       4       V! RV,          4       S P                  V4      o\        S P                  SV4      4       EF  w  r\        WX,          ^,           \        WX^,           ,          ^,           ^4      4      p
V! RV,          4       VV V3R lV
 4       pV! \        VSV4      P	                  4       4       V! RV,          4       V3R lV
 4       pV! \        VSV4      P	                  4       4       V! RV,          4       S P                  '       d]   S P                  P                  S8X  dB   S P                  P                  V
9   d'   V
P                  S P                  P                  4      pMRp\        R V	 4       4      p\        V4       F  p. p\        V	4       Fr  w  ppV\        V4      8  d   VP                  R4       K)  VV8X  d   S P                  P                   MRpVP                  S P#                  VV,          VVR7      4       Kt  	  V! \        VSV4      P	                  4       4       V! RV,          4       K  	  EK  	  RP%                  V4      # )r%  r  c              3   L   <"   T F  pSP                  SVSR 4      x  K  	  R# 5ir'  r(  r)  s   & r7   r  ._CLIDemoCalendar.formatyear.<locals>.<genexpr>  r-  r  c              3   (   <"   T F  pSx  K	  	  R # 5ir4   r[   r/  s   & r7   r  r    r1  r2  Nc              3   8   "   T F  p\        V4      x  K  	  R # 5ir4   r4  r5  s   & r7   r  r    r7  r8  ra   r  )r   r9  r:  r   r!  r  r   r   rz   r;  r<  r  r   r   indexr   r   r   r  )r6   r  r  r  r=  r   r>  r?  rp   r@  r   r  rA  	month_posrB  rC  rD  r*  r6  r   r+  r0  s   ff&&&&              @@r7   rE  _CLIDemoCalendar.formatyear  s\    1I1I1IEQ;?HH	$w-

xz!qS'1
2
9
9
;<	$q&	&&q)!$"8"8!"DEHQ13q5#a1gai"45Fd1fI&$&El5(A.5578d1fI.v.Gl7Ha0779:d1fI """&&++w6&&,,6"LL););)A)AB	 	 1S11F6]'nFAsCH}R( 789nD..22$   OOCFASOI - ,uh299;<$( #/ FJ wwqzr:   r  r4   rK  rL  )r@   rA   rB   rC   r8   r   r  rE  rD   rE   r  r  s   @@r7   r  r    s%     +
$ 
,02 2r:   r  c                   6   a a ] tR tRt oRV 3R lltRtVtV ;t# )_CLIDemoLocaleCalendari  c                4   < \         SV `  ! V/ VB  Wn        R # r4   r  r  s   &&*,r7   r8   _CLIDemoLocaleCalendar.__init__  r  r:   r  r4   )r@   rA   rB   rC   r8   rD   rE   r  r  s   @@r7   r  r    s     + +r:   r  c                 d    \         T u;8:  d   \        8:  g   M \        V 4      hV \        n        R # r4   )r+   r1   r   r=  r   r   s   &r7   r   r     s!    \+V+!,//!ANr:   c                0    \        \        WV4      4       R# )z1Prints multi-column formatting for year calendarsN)r   r<  colsr+  spacings   &&&r7   rg   rg     s    	,tw
/0r:   c                L   a VR,          pVP                  V3R lV  4       4      # )zEReturns a string formatted from n strings, centered within n columns.r   c              3   D   <"   T F  qP                  S4      x  K  	  R # 5ir4   r   )r   r=  r+  s   & r7   r  formatstring.<locals>.<genexpr>  s     9Dq**Ds    r  r  s   &f&r7   r<  r<    s!    sNG<<9D999r:   i  c                    V R,          w  rr4rV\         P                  ! W^4      P                  4       \        ,
          V,           ^,
          pV^,          V,           pV^<,          V,           p	V	^<,          V,           p
V
# )zBUnrelated but handy function to calculate Unix timestamp from GMT.:NrN  N)r{   r|   	toordinal
_EPOCH_ORD)tupler   r   r   hourminutesecondr   hoursminutessecondss   &          r7   r   r   !  sh    -22Y*DF==a(224zACG!KDGdNEBhGbj6!GNr:   c                 p	   ^ RI pVP                  RR7      pVP                  R4      pVP                  R4      pVP                  RR\        ^RR	7       VP                  R
R\        ^RR	7       VP                  RR\        ^RR	7       VP                  RR\        ^RR	7       VP                  RRRRR7       VP                  RRRRR7       VP                  RRRRR7       VP                  RRR R6R"R#7       VP                  R$R%\        ^ R&R	7       VP                  R'R(\        R)R*7       VP                  R+R(\        R,R*7       VP                  V 4      pVP                  '       d:   VP                  '       g(   VP                  R-4       \        P                  ! ^4       VP                  VP                  3p\        P                  P                  4       pVP                  R!8X  Ed5   VP                  '       d(   VP                  R.4       \        P                  ! ^4       VP                  '       d   \!        VR/7      pM
\#        4       pVP%                  VP&                  4       VP                  p	V	f   \        P(                  ! 4       p	\+        WP,                  R07      p
\        P.                  P0                  P2                  pVP4                  f&   V! VP6                  ! VP4                  3/ V
B 4       R# V! VP6                  ! VP4                  3/ V
B 4       R# VP                  '       d   \9        WvR17      pM\;        VR27      pVP%                  VP&                  4       \+        VP<                  VP>                  R37      p
VP                  f    VP@                  V
R4&   VPB                  V
R5&   M\E        VP                  4       VP4                  f   VPF                  ! VP4                  3/ V
B pMTVP                  f   VPF                  ! VP4                  3/ V
B pM(VPH                  ! VP4                  VP                  3/ V
B p\        P.                  P2                  pVP                  '       d@   VPK                  VP                  4      p\        P.                  P0                  P2                  pV! V4       R# )7r   NT)colorztext only argumentszhtml only argumentsz-wz--widthz width of date column (default 2))typedefaulthelpz-lz--linesz)number of lines for each week (default 1)z-sz	--spacingz"spacing between months (default 6)z-mz--monthszmonths per row (default 3)z-cz--cssr  zCSS to use for page)r  r  z-Lz--localez)locale to use for month and weekday namesz-ez
--encodingzencoding to use for outputz-tz--typetexthtmlzoutput type (text or html))r  choicesr  z-fz--first-weekdayzAweekday (0 is Monday, 6 is Sunday) to start each week (default 0)r   ?zyear number)nargsr  r  r   zmonth number (1-12, text only)z/if --locale is specified --encoding is requiredzincorrect number of argumentsr  )ru  rt  )r  r  r  )r  r  r=  r   )r  r  )&argparseArgumentParseradd_argument_groupadd_argumentint
parse_argsr  ru  errorrq  exitr{   r|   todayr  r   r   r   r   first_weekdayrr  dictrt  stdoutbufferwriter   rv  r  r  r   linesr  r   r   rE  r  rs  )r  r  parser	textgroup	htmlgroupoptionsr  r  r6  ru  optdictr  results   &            r7   mainr  +  s   $$4$0F))*?@I))*?@Ii!/  
 i!8  
 k!1  
 j!)  
 g"  
 j8  
 l)  
 h )	   !P  
   
 -   %G~~~g...FG^^W---FMM!E||v===LL89HHQK>>>$F3C.CG112##--/Hkk:

!!''<<#$$UZZ;7;<#$$W\\=W=>>>>(uLC"7CG112'--8== "??GCL">>GCLGMM*<<^^EJJ:':F]]"^^GLL<G<F__W\\7==LGLF

  ]]7#3#34FJJ%%++Efr:   __main__)r         r     r  r	  r  r  r	  r  r	  r  r4   )Ir   rq  r{   enumr   r   r  r  	itertoolsr   __all__
ValueErrorr  
IndexErrorr   r   rY   r   r   r   r^   r   r   r   r   r   r	   r
   r   r   r   r   r   r   objectr   r   r   r  r  r   r   r  r  r=  r   r   r   r   r   r   r   r"  r  r   r   r  r   rE  r   rH  r   	_colwidth_spacingrg   r<  EPOCHr|   r  r  r   r  r@   r[   r:   r7   <module>r     s  7   %  
! 
! 5 
!7H 
!
!#
!%/
!1:
!<H
!
!%
!'.
!07
!9C
! 
! "
! $0
! 2<
! >H
! 	
! &	
! (6	
! 8L	
!
  
!
 ".
! 
! 
! %
! '1
! 3:
! 
! 
! "
! $*
! 
! !
! #,
! .8
! :D
! 
! 
! !,
! .8
! :B
! 
!  
! 	
@
J @X* X
K G    '   	< & ( $$ d#
d#
B
G:'?EJv EJPu<8 u<pF@8 F@R
; 
;O O*H H(e| eP+/1A + N  "
 ##	
||

))	<<	 	 $X 1
 !*8 : 	]]5!Q'113
od zF r:   