Diferencia entre revisiones de «tmElements t»

De ArduWiki
Saltar a: navegación, buscar
(Página creada con «'''tmElents_t''' es una matriz de seis (6) elementos que proporciona la libreria TimeLib.h y que permite manipular de manera facil (sin tener que usar el Tiempo Unix) todos...»)
 
(Ejemplo 1)
Línea 32: Línea 32:
  
 
== Ejemplo 1 ==
 
== Ejemplo 1 ==
 +
En este ejemplo usamos la función [[makeTime()]] para crear el Tiempo Unix de una fecha-hora. Ejemplo 2019-3-21 8:00:00
 +
 +
<syntaxhighlight lang="c++">
 +
#include <TimeLib.h>
 +
void setup(){
 +
  Serial.begin(115200);
 +
  tmElements_t tx;
 +
  tx.Second = 0;
 +
  tx.Minute = 0;
 +
  tx.Hour = 8;
 +
  tx.Day = 21;
 +
  tx.Month = 3;
 +
  tx.Year = 49;  //2019-1970
 +
  time_t tiempo = makeTime(tx);
 +
  Serial.println(tiempo);  //1553155200
 +
}
 +
void loop(){
 +
  //Nada
 +
}
 +
</syntaxhighlight>
 +
 +
== Ejemplo 2 ==
 +
En este ejemplo usamos la función [[makeTime()]] para crear el Tiempo Unix de una fecha-hora. Ejemplo 2019-3-21 8:00:00
 +
 +
<syntaxhighlight lang="c++">
 +
#include <TimeLib.h>
 +
void setup(){
 +
  Serial.begin(115200);
 +
  tmElements_t tx;
 +
  tx.Second = 0;
 +
  tx.Minute = 0;
 +
  tx.Hour = 8;
 +
  tx.Day = 21;
 +
  tx.Month = 3;
 +
  tx.Year = 49;  //2019-1970
 +
  time_t tiempo = makeTime(tx);
 +
  Serial.println(tiempo);  //1553155200
 +
}
 +
void loop(){
 +
  //Nada
 +
}
 +
</syntaxhighlight>
  
 
== Vea tambien ==
 
== Vea tambien ==

Revisión del 19:09 22 mar 2019

tmElents_t es una matriz de seis (6) elementos que proporciona la libreria TimeLib.h y que permite manipular de manera facil (sin tener que usar el Tiempo Unix) todos los elementos necesarios para definir una fecha-hora.

Sintaxis

tmElements_t variable;

Parámetros

variable
Nombre de la variable que definiras.

Métodos

Metodo Descripcion
.Second Segundo (0~59)
.Minute Minuto (0~59)
.Hour Hora (0~23)
.Day Dia (1~31)
.Month Mes (1~12)
.Year Año (0~99)

Comentarios

Advertencias

Ejemplo 1

En este ejemplo usamos la función makeTime() para crear el Tiempo Unix de una fecha-hora. Ejemplo 2019-3-21 8:00:00

#include <TimeLib.h>
void setup(){
   Serial.begin(115200);
   tmElements_t tx;
   tx.Second = 0;
   tx.Minute = 0;
   tx.Hour = 8;
   tx.Day = 21;
   tx.Month = 3;
   tx.Year = 49;   //2019-1970
   time_t tiempo = makeTime(tx);
   Serial.println(tiempo);   //1553155200
}
void loop(){
   //Nada
}

Ejemplo 2

En este ejemplo usamos la función makeTime() para crear el Tiempo Unix de una fecha-hora. Ejemplo 2019-3-21 8:00:00

#include <TimeLib.h>
void setup(){
   Serial.begin(115200);
   tmElements_t tx;
   tx.Second = 0;
   tx.Minute = 0;
   tx.Hour = 8;
   tx.Day = 21;
   tx.Month = 3;
   tx.Year = 49;   //2019-1970
   time_t tiempo = makeTime(tx);
   Serial.println(tiempo);   //1553155200
}
void loop(){
   //Nada
}

Vea tambien

Referecias