Mine værktøjer
Du er her: Forside diverse filer til download mm. ugeoversigt.py Kildetekst
Handlinger tilknyttet webside

ugeoversigt.py Kildetekst

af Lars Bauer JørgensenSidst opdateret 07/10 2008 10:14

http://www.eksperten.dk/spm/785726

Klik her for at hente fil

Størrelse: 2.5 kB - Filtype text/python-source

Indhold af fil-indholdsobjekt

#!/usr/bin/env python
"""Print a week on screen."""
import datetime # cgi

def Ny_Time( Minuts, Time, Timer ):
    if Minuts:
        TimerStrg=[]
        TimerStrg.append( '\n  <table class="time"><th>%s</th><tr><td>' % ( Time ) )
        TimerStrg.append( '\n   <table class="minuts"> <tr><td>' )
        TimerStrg.append( '</td><td>'.join( Minuts ) )
        TimerStrg.append( '\n   </td></tr></table>' )
        TimerStrg.append( '\n  </td></tr></table>' )
        Timer.append( "".join( TimerStrg ) )

def Nyt_Dogn( Timer, Dag, Uge ):
    if Timer:
        Uge.append( '\n<table class="dag"><th>%s</th><tr><td>' %  Dag  )
        Uge.append( '\n <table class="timer"><tr><td>' )
        Uge.append( '</td></tr><tr><td>'.join( Timer ) )
        Uge.append( '\n </td></tr></table>' )
        Uge.append( '\n</td></tr></table>' )

def uge(optaget=[]):
    D = datetime.datetime.today()
    D1 = D.day - 1
    H1 = D.hour - 1
    Uge = []
    Dag = []
    Timer = []
    Time = []
    Minuts = []
    Min = datetime.timedelta(0,60) # 1 minut
    for m in range( 7 * 24 * 60 ) :
        
        D += Min 
        Optaget = [ True for (x,y) in optaget if x <= D < y ]

        if H1 != D.hour:
            H1 = D.hour
            Ny_Time( Minuts, Time, Timer )
            Minuts = []
            Time =  "%02d" % ( D.hour)

        if D1 != D.day:
            D1 = D.day
            Nyt_Dogn( Timer, Dag, Uge )
            Dag = D.strftime( "%A" )
            Minuts = []
            Timer = []
        if Optaget:
            Minuts.append( '<span id="Optaget">%02d</span>' % ( D.minute ) )
        else:
            Minuts.append( "%02d" % ( D.minute ) )

    # Saml lige resten op 
    Ny_Time( Minuts, Time, Timer )
    Nyt_Dogn( Timer, Dag, Uge )
    return Uge        

Delta1 = datetime.timedelta(0,6720)
Delta2 = datetime.timedelta(0,600)
D = datetime.datetime.today()
Optaget = []
for t in range( 12 ):
    D+=Delta1
    S = D + Delta2
    Optaget.append( (D,S) )
Style = """
<style>
  #Optaget { background-color:red ;
  }
  td { font-size: xx-small; }
  table.uge { table-layout:auto ; }
  table.dag { width: auto; }
  table.time { width: 100%; }
  #tright { align: right; }
  .time { border-style: solid; }
  .dag { border-style: dotted; }
</style>
"""
print "Content-type: text/html\n"
print "<html>\n"
print Style
print '<a target="_blank" href="http://bauerdata.bauerhost.dk/diverse-filer-til-download-mm/ugeoversigt/view">Hent kildekoden her</a>' 
print "\n".join( uge( optaget=Optaget ) ) 
print "</html>"
« august 2018 »
søn man tir ons tor fre lør
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
Chat Rooms
Dyrk motion

Trim ballerup

 

Powered by Plone, the Open Source Content Management System