Created
August 11, 2014 18:40
-
-
Save fmagrosoto/52c619d6610b5da65680 to your computer and use it in GitHub Desktop.
Extraer la fecha de hoy en español desde una clase de javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * MOSTRAR FECHA DE HOY | |
| * | |
| * Fecha de hoy en el siguiente formato | |
| * <i>nDia dia 'de' Nmes 'de' agno</i> | |
| * @author Fernando Magrosoto V. | |
| * @param {string} contenedor El ID del contenedor donde poner la fecha | |
| */ | |
| var class_FechaHoy = function(contenedor) | |
| { | |
| // Propiedades | |
| this.contenedor = contenedor; | |
| this.hoy = new Date(); | |
| this.dia = this.hoy.getDay(); | |
| this.mes = this.hoy.getMonth(); | |
| this.agno = this.hoy.getFullYear(); | |
| this.fecha = this.hoy.getDate(); | |
| // MÉTODOS | |
| this.pintarFecha = function() | |
| { | |
| var arreglo = this.XnomDia(this.dia); | |
| arreglo += " " + this.fecha; | |
| arreglo += " de " + this.XnomMes(this.mes); | |
| arreglo += " de " + this.agno; | |
| document.getElementById(this.contenedor).innerHTML = arreglo; | |
| }; | |
| this.XnomDia = function(dia) | |
| { | |
| var dias = [ | |
| 'Domingo', | |
| 'Lunes', | |
| 'Martes', | |
| 'Miércoles', | |
| 'Jueves', | |
| 'Viernes', | |
| 'Sábado']; | |
| return dias[dia]; | |
| }; | |
| this.XnomMes = function(mes) | |
| { | |
| var meses = [ | |
| 'Enero', | |
| 'Febrero', | |
| 'Marzo', | |
| 'Abril', | |
| 'Mayo', | |
| 'Junio', | |
| 'Julio', | |
| 'Agosto', | |
| 'Septiembre', | |
| 'Octubre', | |
| 'Noviembre', | |
| 'Diciembre']; | |
| return meses[mes]; | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment