Código de JavaScript - Sumar días a una fecha omitiendo sábados, domingos y festivos en JavaScript

Requerimientos

El código HTML esta desarrollado en .NET

v1.0

Publicado el 14 de Octubre del 2016gráfica de visualizaciones de la versión: v1.0
4.895 visualizaciones desde el 14 de Octubre del 2016
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
 
   <script type="text/javascript">
 
       function addDaysToDate()
       {
            var Festivos = Array();
            Festivos[0] = new Array(1, 1);
            Festivos[1] = new Array(11, 1);
            Festivos[2] = new Array(21, 3);
            Festivos[3] = new Array(24, 3);
            Festivos[4] = new Array(25, 3);
            Festivos[5] = new Array(27, 3);
            Festivos[6] = new Array(1, 5);
            Festivos[7] = new Array(9, 5);
            Festivos[8] = new Array(30, 5);
            Festivos[9] = new Array(6, 6);
            Festivos[10] = new Array(4, 7);
            Festivos[11] = new Array(20, 7);
            Festivos[12] = new Array(7, 8);
            Festivos[13] = new Array(15, 8);
            Festivos[14] = new Array(17, 10);
            Festivos[15] = new Array(7, 11);
            Festivos[16] = new Array(14, 11);
            Festivos[17] = new Array(8, 12);
            Festivos[18] = new Array(25, 12);
 
            var dias = document.getElementById("<%=TxtNaturaleza.ClientID%>").value;
 
            var Fecha = new Date();
            var sFecha = fecha || (Fecha.getDate() + "/" + (Fecha.getMonth() + 1) + "/" + Fecha.getFullYear());
            var sep = sFecha.indexOf('/') != -1 ? '/' : '-';
            var aFecha = sFecha.split(sep);
            var fecha = aFecha[2] + '/' + aFecha[1] + '/' + aFecha[0];
            fecha = new Date(fecha);
            var i = 0;
            while (i < dias)
            {
                fecha.setDate(fecha.getDate() + parseInt(1));
                if (fecha.getDay() == 6 || fecha.getDay() == 0)
                {
                    i--;
                }
 
                for (var x in Festivos){
                    var days = Festivos[x];
                    var elementos = days.toString();
                    var elem = elementos.split(",");
                    var dia = elem[0];
                    var mes = elem[1];
                    if(dia == fecha.getDate() && mes == fecha.getMonth() + 1)
                        i--;
                }
 
                i++;
            }
 
            var anno = fecha.getFullYear();
            var mes = fecha.getMonth() + 1;
            var dia = fecha.getDate();
            mes = (mes < 10) ? ("0" + mes) : mes;
            dia = (dia < 10) ? ("0" + dia) : dia;
            var fechaFinal = dia + sep + mes + sep + anno;
 
            document.getElementById('<%=SelDateFechaVencimiento.ClientID %>').value = fechaFinal;
       }
   </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="btnEnviar" runat="server" Text="Button" OnClientClick="javascript:addDaysToDate();" />
        <%--<asp:TextBox ID="TxtNaturaleza" onkeydown="addDaysToDate(this);" runat="server"></asp:TextBox>--%>
        <asp:TextBox ID="TxtNaturaleza" runat="server" Width="50"></asp:TextBox>
        <asp:TextBox ID="SelDateFechaVencimiento" runat="server" Width="100"></asp:TextBox>
    </div>
    </form>
</body>
</html>



Comentarios sobre la versión: v1.0 (0)


No hay comentarios
 

Comentar la versión: v1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3711