Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di Legnetto
    Registrato dal
    May 2002
    Messaggi
    1,419

    Selezionare le festività in rosso

    In una pagina che elenca le scadenze d'agenda avrei bisogno di evidenziare dopo la data anche il giorno della settimana, con i sabati e le domeniche in rosso, anche le festività devono essere differenziate dagli altri giorni.
    La prima parte(giorno della settimana e sab/dom in rosso)l'ho implementata senza problemi, non riesco a capire come fare però per evidenziare i giorni festivi.
    Potrei crearmi un'elenco a manina con le festività fisse(Natale ecc....), però ad esempio il lunedi dopo Pasqua non cade sempre nello stesso giorno.
    Come posso fare?
    Ciao e grazie
    Legnetto

  2. #2
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    devi modificare la data del Santo Patrono, San Saturnino, ed il giorno di Santa Barbara, che io festeggio

    codice:
        '--------------------------------------------------------
        'restituisce un vettore di date festive
        'viene passato l'anno
        '--------------------------------------------------------
        Public Function DateFestive(ByVal anno%) As DateTime()
            Dim Festivita() As DateTime = { _
            New DateTime(anno, 1, 1), _
            New DateTime(anno, 1, 6), _
            New DateTime(anno, 4, 25), _
            New DateTime(anno, 5, 1), _
            New DateTime(anno, 6, 2), _
            New DateTime(anno, 8, 15), _
            New DateTime(anno, 10, 30), _
            New DateTime(anno, 11, 1), _
            New DateTime(anno, 12, 4), _
            New DateTime(anno, 12, 8), _
            New DateTime(anno, 12, 25), _
            New DateTime(anno, 12, 26), _
            PasquaGregoriana(anno), _
            PasquaGregoriana(anno).AddDays(1)}
            Festivita.Sort(Festivita)
            Return Festivita
        End Function
    
        '------------------------------------------------------------------
        'Restituisce vero o falso a seconda che la data passata sia
        'festiva o meno
        '------------------------------------------------------------------
        Public Overloads Function IsFestive(ByVal Data As Date) As Boolean
            Dim Anno%, Mese%, Giorno%
    
            IsFestive = False
    
            Anno = Data.Year 'Year(Data)
            Mese = Data.Month 'Month(Data)
            Giorno = Data.Day 'Day(Data)
    
            If Mese = 1 And Giorno = 1 Then '1 gennaio
                IsFestive = True
            ElseIf Mese = 1 And Giorno = 6 Then '6 gennaio
                IsFestive = True
            ElseIf Mese = 4 And Giorno = 25 Then '25 aprile
                IsFestive = True
            ElseIf Mese = 5 And Giorno = 1 Then '1 maggio
                IsFestive = True
            ElseIf Mese = 6 And Giorno = 2 Then '2 giugno
                IsFestive = True
            ElseIf Mese = 8 And Giorno = 15 Then '15 agosto
                IsFestive = True
            ElseIf Mese = 10 And Giorno = 30 Then '30 ottobre San Saturnino Patrono
                IsFestive = True
            ElseIf Mese = 11 And Giorno = 1 Then '1 novembre
                IsFestive = True
            ElseIf Mese = 12 And Giorno = 4 Then '4 dicembre Santa Barbara
                IsFestive = True
            ElseIf Mese = 12 And Giorno = 8 Then '8 dicembre
                IsFestive = True
            ElseIf Mese = 12 And Giorno = 25 Then '25 dicembre
                IsFestive = True
            ElseIf Mese = 12 And Giorno = 26 Then '26 dicembre
                IsFestive = True
    
            Else
                Dim Pasqua As DateTime
                Pasqua = PasquaGregoriana(Anno)
                Dim LunediAngelo As DateTime
                LunediAngelo = Pasqua.AddDays(1) 'DateAdd("d", 1, Pasqua)
                If Mese = Pasqua.Month And Giorno = Pasqua.Day Then
                    IsFestive = True
                ElseIf Mese = LunediAngelo.Month And Giorno = LunediAngelo.Day Then
                    IsFestive = True
                End If
            End If
    
        End Function
        Public Overloads Function IsFestive(ByVal Anno%, ByVal Mese%, ByVal Giorno%) As Boolean
            Return IsFestive(New DateTime(Anno, Mese, Giorno))
        End Function
    
        '---------------------------------------------------------------------------------------
        ' Routine che restituisce il giorno della Pasqua passando 
        ' come parametro l'anno. L'algoritmo è valido per tutti gli anni 
        ' nel Calendario Gregoriano, ossia dal 1583 in poi. 
        ' Basata su un metodo sviluppato nel 1876 e che comparve 
        ' nell'Ecclesiastical Calendar di Butcher, poi ripubblicato: 
        ' - da Spencer Jones in "General Astronomy" del 1922 
        ' - nel Journal of the British Astronomical Association, del 1977 
        ' - da Jean Meeus in "Astronomical Formulae for Calculators" del 1979. 
        '
        ' Pasqua cade nella domenica seguente al primo plenilunio ecclesiastico dopo il 21 marzo
        '---------------------------------------------------------------------------------------
        Public Function PasquaGregoriana(ByVal anno%) As Date
            Dim a%, b%, c%, p%, q%, r%
            a = anno% Mod 19 : b = anno% \ 100 : c = anno% Mod 100
            p = (19 * a + b - (b \ 4) - ((b - ((b + 8) \ 25) + 1) \ 3) + 15) Mod 30
            q = (32 + 2 * ((b Mod 4) + (c \ 4)) - p - (c Mod 4)) Mod 7
            r = (p + q - 7 * ((a + 11 * p + 22 * q) \ 451) + 114)
            PasquaGregoriana = DateSerial(anno%, r \ 31, (r Mod 31) + 1)
        End Function
    Pietro

  3. #3
    Utente di HTML.it L'avatar di Legnetto
    Registrato dal
    May 2002
    Messaggi
    1,419
    Che dire....
    Sono commosso.... :maLOL:
    Sto usando anche le faccine..... VVoVe:
    A parte gli scherzi grazie mille Pietro
    Adesso guardo bene il codice

    Legnetto

  4. #4
    Function IsFestive
    :maLOL: :maLOL: :maLOL: :maLOL:

  5. #5
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    Originariamente inviato da Jc_
    Function IsFestive

    :maLOL: :maLOL: :maLOL: :maLOL:
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.