equal
deleted
inserted
replaced
63 |
63 |
64 Outputs a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. |
64 Outputs a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. |
65 """ |
65 """ |
66 rfcdate = formatdate(epoch_seconds) |
66 rfcdate = formatdate(epoch_seconds) |
67 return '%s GMT' % rfcdate[:25] |
67 return '%s GMT' % rfcdate[:25] |
|
68 |
|
69 # Base 36 functions: useful for generating compact URLs |
|
70 |
|
71 def base36_to_int(s): |
|
72 """ |
|
73 Convertd a base 36 string to an integer |
|
74 """ |
|
75 return int(s, 36) |
|
76 |
|
77 def int_to_base36(i): |
|
78 """ |
|
79 Converts an integer to a base36 string |
|
80 """ |
|
81 digits = "0123456789abcdefghijklmnopqrstuvwxyz" |
|
82 factor = 0 |
|
83 # Find starting factor |
|
84 while True: |
|
85 factor += 1 |
|
86 if i < 36 ** factor: |
|
87 factor -= 1 |
|
88 break |
|
89 base36 = [] |
|
90 # Construct base36 representation |
|
91 while factor >= 0: |
|
92 j = 36 ** factor |
|
93 base36.append(digits[i / j]) |
|
94 i = i % j |
|
95 factor -= 1 |
|
96 return ''.join(base36) |