Individuare se presente l'ora legale

colomber

Utente Attivo
4 Dic 2012
232
1
18
Sapete come individuare se in una determinata data é in vigore l'ora legale?


la data é di questo tipo:

strftime("%e %B %Y", strtotime("+2 month"));



grazie
 
ho creato una funzione nel database che restituisce 0 o 1
che richiamo nella query in questo modo
Codice:
dbo.summertime(iv_year, iv_month, iv_day) as SummerTime


Codice:
create function SummerTime(@Year int, @Month int, @Day int)

returns int
as
    begin

    declare @SummerTime int, @aa int, @bb int, @cc int, @STBeg_y int, @STBeg_m int, @STBeg_d int, @STEnd_y int, @STEnd_m int, @STEnd_d int

    set @aa = -CEILING(-5*@Year/4)
    set @bb = @aa+4
    set @cc = @aa+1

    set @STBeg_y = @Year
    set @STBeg_m = 3
    set @STBeg_d = 31-(@bb+7*CEILING(-@bb/7)) 

    set @STEnd_y = @Year
    set @STEnd_m = 10
    set @STEnd_d = 31-(@cc+7*CEILING(-@cc/7))

    set @SummerTime = CASE WHEN
        dbo.date(@Year, @Month, @Day) >= dbo.date(@STBeg_y, @STBeg_m, @STBeg_d) and
        dbo.date(@Year, @Month, @Day) <  dbo.date(@STEnd_y, @STEnd_m, @STEnd_d) then 1 else 0 end

    return @SummerTime    
    end
go
penso ti sarà facile tradurla in ogni altro linguaggio,
i parametri necessari sono anno, mese e giorno
ciao
Marino
 
ho dimenticato la funzione "date" calcola la data da giorno, mese e anno

Codice:
create function Date(@Year int, @Month int, @Day int)

returns datetime
as
    begin
    return dateadd(month,(12*@Year)-22801+@Month,@Day-1)
    end
go
 
$year = strftime("%Y");

$initDay = (31 - ( floor(5 * $year / 4) + 4) % 7) ;
$endDay = (31 - ( floor(5 * $year / 4) + 1) % 7) ;


trova i giorni in cui si cambia l'ora manca il mese che é sempre nella prima marzo e nella seconda ottobre
 
Ultima modifica:

Discussioni simili