|
Lines 39-44
import string
Link Here
|
| 39 |
import re |
39 |
import re |
| 40 |
import sys |
40 |
import sys |
| 41 |
import time |
41 |
import time |
|
|
42 |
import calendar |
| 42 |
import types |
43 |
import types |
| 43 |
import array |
44 |
import array |
| 44 |
import univention.uldap |
45 |
import univention.uldap |
|
Lines 215-240
def encode_s4_resultlist(s4_resultlist):
Link Here
|
| 215 |
return s4_resultlist |
216 |
return s4_resultlist |
| 216 |
|
217 |
|
| 217 |
|
218 |
|
| 218 |
def unix2s4_time(l): |
219 |
def samba2s4_time(unix_ts): |
| 219 |
d = 116444736000000000L # difference between 1601 and 1970 |
220 |
delta = 116444736000000000L # difference between 1601 and 1970 |
| 220 |
return long(time.mktime(time.gmtime(time.mktime(time.strptime(l, "%Y-%m-%d")) + 90000))) * 10000000 + d # 90000s are one day and one hour |
221 |
as_nanoseconds = unix_ts * 10000000 |
|
|
222 |
return as_nanoseconds + delta |
| 221 |
|
223 |
|
| 222 |
|
224 |
|
| 223 |
def s42unix_time(l): |
225 |
def s42samba_time(s4_ts): |
| 224 |
d = 116444736000000000L # difference between 1601 and 1970 |
226 |
delta = 116444736000000000L # difference between 1601 and 1970 |
| 225 |
return time.strftime("%d.%m.%y", time.gmtime((l - d) / 10000000)) |
227 |
if s4_ts == 0: |
|
|
228 |
return 0 |
| 229 |
nanoseconds_since_epoch = s4_ts - delta |
| 230 |
return nanoseconds_since_epoch / 10000000 |
| 226 |
|
231 |
|
| 227 |
|
232 |
|
| 228 |
def samba2s4_time(l): |
233 |
def unix2s4_time(iso_date): |
| 229 |
d = 116444736000000000L # difference between 1601 and 1970 |
234 |
since_epoch = calendar.timegm(time.strptime(iso_date, '%Y-%m-%d')) |
| 230 |
return long(time.mktime(time.localtime(l))) * 10000000 + d |
235 |
return samba2s4_time(since_epoch) |
| 231 |
|
236 |
|
| 232 |
|
237 |
|
| 233 |
def s42samba_time(l): |
238 |
def s42unix_time(s4_ts): |
| 234 |
if l == 0: |
239 |
since_epoch = s42samba_time(s4_ts) |
| 235 |
return l |
240 |
return time.strftime('%Y-%m-%d', time.gmtime(since_epoch)) |
| 236 |
d = 116444736000000000L # difference between 1601 and 1970 |
|
|
| 237 |
return long(((l - d)) / 10000000) |
| 238 |
|
241 |
|
| 239 |
# mapping funtions |
242 |
# mapping funtions |
| 240 |
|
243 |
|
| 241 |
- |
|
|
| 242 |
-- |
| 243 |
.../modules/univention/s4connector/s4/__init__.py | 9 +++++---- |
244 |
.../modules/univention/s4connector/s4/__init__.py | 9 +++++---- |
| 244 |
1 file changed, 5 insertions(+), 4 deletions(-) |
245 |
1 file changed, 5 insertions(+), 4 deletions(-) |