o
    .j                     @   sX   d Z ddlZddlmZmZmZ ddlmZmZ ddlm	Z	 G dd de	Z
ee
 dS )	a  
hCalendar: A microformat for serializing iCalendar data
          (http://microformats.org/wiki/hcalendar)

Here is a sample event in an iCalendar:

BEGIN:VCALENDAR
PRODID:-//XYZproduct//EN
VERSION:2.0
BEGIN:VEVENT
URL:http://www.web2con.com/
DTSTART:20051005
DTEND:20051008
SUMMARY:Web 2.0 Conference
LOCATION:Argent Hotel\, San Francisco\, CA
END:VEVENT
END:VCALENDAR

and an equivalent event in hCalendar format with various elements optimized appropriately.

<span class="vevent">
 <a class="url" href="http://www.web2con.com/">
  <span class="summary">Web 2.0 Conference</span>:
  <abbr class="dtstart" title="2005-10-05">October 5</abbr>-
  <abbr class="dtend" title="2005-10-08">7</abbr>,
 at the <span class="location">Argent Hotel, San Francisco, CA</span>
 </a>
</span>
    N)datedatetime	timedelta   )CRLFregisterBehavior)VCalendar2_0c                   @   s   e Zd ZdZedddZdS )	HCalendar	HCALENDARNTc                    s  |pt  ddfdd  fdd}|j}|D ]}|dt  d7 |d	}|r>|d
| d t  d7 |d}	|	rO|d|	 d t  |d}
|
rt|
tkrad}d}n
t|
tkrkd}d}|d|
	||
	| |d}|s|d}|r||
 }|r|}t|tkr|t
dd }|d|	||	| |d}|r|d| d t  |d}|r|d| d t  |r؈d8 |dt  d8 |dt  q|p S ) zv
        Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar)
        r      c                      s   d   S )N  r   )leveltabwidthr   F/home/thesage/.local/lib/python3.10/site-packages/vobject/hcalendar.pyindent4   s   z#HCalendar.serialize.<locals>.indentc                    s        |  d S )N)write)s)r   outbufr   r   out7   s   z HCalendar.serialize.<locals>.outz<span class="vevent">r   urlz<a class="url" href="z">summaryz<span class="summary">z</span>:dtstartz	%A, %B %ez%Y%m%dz%A, %B %e, %H:%Mz%Y%m%dT%H%M%S%zz3<abbr class="dtstart", title="{0!s}">{1!s}</abbr>
dtendduration)daysz3- <abbr class="dtend", title="{0!s}">{1!s}</abbr>
locationzat <span class="location">z</span>descriptionz<div class="description">z</div>z</a>)sixStringIOvevent_listr   getChildValuetyper   r   formatstrftimer   getvalue)clsobjbuf
lineLengthvalidater   veventseventr   r   r   
timeformatmachiner   r   humanr   r   r   )r   r   r   r   r   	serialize*   sn   








zHCalendar.serialize)NNT)__name__
__module____qualname__nameclassmethodr0   r   r   r   r   r	   '   s    r	   )__doc__r   r   r   r   baser   r   	icalendarr   r	   r   r   r   r   <module>   s    [