Attachment 'EventCalendar-easytime.patch'

Download

   1 --- EventCalendar-094.py	2006-02-25 00:41:43.000000000 -0800
   2 +++ EventCalendar-easytime.py	2006-02-25 00:53:40.000000000 -0800
   3 @@ -510,21 +510,36 @@
   4      str_hour = ''
   5      str_min = ''
   6      
   7 -    if len(str_time) == 4:
   8 -        # hour+minute
   9 -        str_hour = str_time[:2]
  10 -        str_min = str_time[2:]
  11 -    
  12 -    elif len(str_time) == 5:
  13 -        # hour+?+minute
  14 -        str_hour = str_time[:2]
  15 -        str_min = str_time[3:]
  16 +    regex_time = '(?P<hour>\\d{1,2})[:]?(?P<minute>\\d{0,2})(?P<meridian_p>[pP][mM]?)?'
  17 +    pattern = re.compile(regex_time)    
  18 +    match = pattern.search(str_time)
  19 +    
  20 +    if match:
  21 +        str_hour = match.group('hour')
  22 +        str_min  = match.group('minute')
  23 +        str_meridian_p = match.group('meridian_p')
  24          
  25      else:
  26          raise ValueError
  27      
  28 +    int_hour = int(str_hour)
  29 +    
  30 +    # convert to 24 hour format
  31 +    if int_hour == 12:
  32 +        int_hour = 0
  33 +	
  34 +    # check for pm
  35 +    if str_meridian_p:
  36 +        int_hour = int_hour + 12
  37 +    
  38 +    #handle null minutes
  39 +    try:
  40 +        int_min = int(str_min)
  41 +    except (TypeError, ValueError):
  42 +        int_min = 0
  43 +    
  44      # It raises exception if the input date is incorrect
  45 -    temp = datetime.time(int(str_hour), int(str_min))
  46 +    temp = datetime.time(int_hour, int_min)
  47  
  48      return temp.hour, temp.minute
  49  
  50 @@ -1271,7 +1286,7 @@
  51  ^\s+start::\s*
  52  (?P<startdate>\d{4}[/-]\d{2}[/-]\d{2})
  53  \s*
  54 -(?P<starttime>\d{2}[:]\d{2})*
  55 +(?P<starttime>\d{1,2}[:]?\d{0,2}([AP][M]?)?)*
  56  \s*
  57  $
  58  """
  59 @@ -1280,7 +1295,7 @@
  60  ^\s+end::\s*
  61  (?P<enddate>\d{4}[/-]\d{2}[/-]\d{2})*
  62  \s*
  63 -(?P<endtime>\d{2}[:]\d{2})*
  64 +(?P<endtime>\d{1,2}[:]?\d{0,2}([AP][M]?)?)*
  65  \s*
  66  $
  67  """
  68 @@ -1380,8 +1395,8 @@
  69          # ERROR
  70          return '','','','','','','','','',''
  71      
  72 -    if (starttime or endtime) and not (starttime and endtime):
  73 -        #debug('no or 2 time field should be specified')
  74 +    if (endtime) and not (starttime):
  75 +        #debug('endtime without starttime')
  76          # ERROR
  77          return '','','','','','','','','',''
  78  
  79 @@ -1420,6 +1435,15 @@
  80          # format time
  81          starttime = u'%02d%02d' %(shour, smin)
  82          endtime = u'%02d%02d' %(ehour, emin)
  83 +    elif (starttime):
  84 +        try:
  85 +            shour, smin = gettimefield(starttime)
  86 +        except (TypeError, ValueError):
  87 +            #debug('invalid time format: %s, %s' % (startdate, enddate))
  88 +            return '','','','','','','','','',''
  89 +
  90 +        starttime = u'%02d%02d' %(shour, smin)
  91 +        endtime = u''
  92      
  93      # check recurrent data
  94      event_len = diffday(startdate, enddate)
  95 @@ -1463,6 +1487,7 @@
  96                  debug('recur_until should precede enddate')
  97                  return '','','','','','','','','',''
  98      
  99 +    
 100      return startdate, starttime, enddate, endtime, bgcolor, description, recur_freq, recur_type, recur_until
 101  
 102  

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-02-25 08:59:09, 2.8 KB) [[attachment:EventCalendar-easytime.patch]]
  • [get | view] (2006-02-25 09:30:01, 2.9 KB) [[attachment:EventCalendar-easytime2.patch]]
  • [get | view] (2006-02-25 09:30:39, 74.9 KB) [[attachment:EventCalendar-easytime2.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.