[GTER] RES: Horario de Verao agora e "fixo" ...

Frederico A C Neves fneves at registro.br
Wed Sep 10 12:05:57 -03 2008


On Wed, Sep 10, 2008 at 11:58:31AM -0300, Frederico A C Neves wrote:
...
> Se tudo estiver correto são somente 6 exceções até 2038. Anexo diffs
> para o Southamerica e o calculo das exceções. Parece mais do que

Parece que a lista não gosta muito de .py vamos tentar com .txt

Fred
-------------- next part --------------
#! /usr/bin/python
import datetime

def ThirdSunFeb(year):
    d1 = datetime.date(year,2,1)
    diff = 14
    if d1.weekday() != 6:
        diff = 6 - d1.weekday() + 14
    return d1 + datetime.timedelta(diff)

print "Easter     Carnival   Retdst"
for a in range(2009,2039):
    # Easter Calculation
    # "Gabriel Zucco Tau" <gabrieltau at gabrieltau.com.br>
    # J.-M.Oudin (1940) 
    # "Explanatory Supplement to the Astronomical Almanac, ed. P.K. Seidelmann (1992)"
    c = a/100
    n = a - 19*(a/19)
    k = (c - 17)/25
    i = c - c/4 - (c-k)/3 +19*n + 15
    i = i - 30*(i/30)
    i = i - (i/28)*(1-(1/28)*(29/(i+1))*((21-n)/11))
    j = a + a/4 + i + 2 - c + c/4
    j = j - 7*(j/7)
    l = i - j
    m = 3 + (l+40)/44
    d = l + 28 - 31*(m/4)
    easter = datetime.date(a,m,d)
    # Carnival Sunday is seven weeks before easter
    carnival = easter - datetime.timedelta(7*7)
    tsf = ThirdSunFeb(a)
    retdst = tsf

    if tsf == carnival:
        # Exception add a week 
        retdst = tsf + datetime.timedelta(7)
        print easter, carnival, retdst, "*"
    else:
        print easter, carnival, retdst


More information about the gter mailing list