This file is indexed.

/usr/share/pyshared/mx/DateTime/timegm.py is in python-egenix-mxdatetime 3.2.1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
""" A timegm() emulation for platforms that do not provide the C lib
    API.

    This is the prototype I used to code the timegm() C emulation in
    mxDateTime. It offers a little more than is really needed...

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2011, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.

"""
from time import *

_debug = 0

def local_offset(ticks):

    if _debug:
        print 'local:',localtime(ticks)
        print 'GMT:',gmtime(ticks)
    (localyear,localmonth,localday,
     localhour,localminute,localsecond,
     localwday,localyday,localdst) = localtime(ticks)
    (gmyear,gmmonth,gmday,
     gmhour,gmminute,gmsecond,
     gmwday,gmyday,gmdst) = gmtime(ticks)
    if gmday != localday:
        localdate = localyear * 10000 + localmonth * 100 + localday
        gmdate = gmyear * 10000 + gmmonth * 100 + gmday
        if localdate < gmdate:
            offset = -86400
        else:
            offset = 86400
    else:
        offset = 0
    return (offset 
            + (localhour - gmhour) * 3600
            + (localminute - gmminute) * 60
            + (localsecond - gmsecond))

def timegm(year,month,day,hour,minute,second,wday,yday,dst):

    try:
        ticks = mktime(year,month,day,hour,minute,second,wday,yday,-1)
        return ticks + local_offset(ticks)
    except OverflowError:
        # Hmm, we may have stumbled into the "missing" hour during a
        # DST switch...
        ticks = mktime(year,month,day,0,0,0,wday,yday,-1) 
        offset = local_offset(ticks)
        return (ticks + offset
                + 3600 * hour
                + 60 * minute
                + second)

def dst(ticks):

    offset = local_offset(ticks)
    for checkpoint in (-8640000,10000000,-20560000,20560000):
        try:
            reference = local_offset(ticks + checkpoint)
        except OverflowError:
            continue
        if reference != offset:
            break
    if _debug:
        print 'given:',offset,'reference:',reference,'(checkpoint:',checkpoint,')'
    return offset > reference

def _test():

    t = 920710000
    oops = 0
    while 1:
        x = apply(timegm,gmtime(t))
        if x != t:
            print 'Ooops:',gmtime(t),'t =',t,'diff =',x-t
            oops = oops + 1
        isdst = localtime(t)[-1]
        if isdst != -1 and isdst != dst(t):
            print 'Ooops: t =',t,'dst() =',dst(t),'isdst =',isdst
            oops = oops + 1
        try:
            t = t + 10011
        except OverflowError:
            break
    if not oops:
        print 'Works.'
        return 1
    else:
        print 'Got %i warnings.' % oops
        return 0

if __name__ == '__main__':
    _test()