Ciro Edgardo Romero
/
FoodDeposit
Sistema de supervision y alarma para deposito de comida de animales
modules/date_and_time/date_and_time.cpp@0:5e7248732177, 2021-05-14 (annotated)
- Committer:
- ciror00
- Date:
- Fri May 14 17:27:28 2021 +0000
- Revision:
- 0:5e7248732177
Trabajo final de la materia Introduccion a los Sistemas Embebidos
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ciror00 | 0:5e7248732177 | 1 | //=====[Libraries]============================================================= |
ciror00 | 0:5e7248732177 | 2 | |
ciror00 | 0:5e7248732177 | 3 | #include "mbed.h" |
ciror00 | 0:5e7248732177 | 4 | |
ciror00 | 0:5e7248732177 | 5 | #include "date_and_time.h" |
ciror00 | 0:5e7248732177 | 6 | |
ciror00 | 0:5e7248732177 | 7 | //=====[Declaration of private defines]====================================== |
ciror00 | 0:5e7248732177 | 8 | |
ciror00 | 0:5e7248732177 | 9 | //=====[Declaration of private data types]===================================== |
ciror00 | 0:5e7248732177 | 10 | |
ciror00 | 0:5e7248732177 | 11 | //=====[Declaration and initialization of public global objects]=============== |
ciror00 | 0:5e7248732177 | 12 | |
ciror00 | 0:5e7248732177 | 13 | //=====[Declaration of external public global variables]======================= |
ciror00 | 0:5e7248732177 | 14 | |
ciror00 | 0:5e7248732177 | 15 | //=====[Declaration and initialization of public global variables]============= |
ciror00 | 0:5e7248732177 | 16 | |
ciror00 | 0:5e7248732177 | 17 | //=====[Declaration and initialization of private global variables]============ |
ciror00 | 0:5e7248732177 | 18 | |
ciror00 | 0:5e7248732177 | 19 | //=====[Declarations (prototypes) of private functions]======================== |
ciror00 | 0:5e7248732177 | 20 | |
ciror00 | 0:5e7248732177 | 21 | //=====[Implementations of public functions]=================================== |
ciror00 | 0:5e7248732177 | 22 | |
ciror00 | 0:5e7248732177 | 23 | char* dateAndTimeRead() |
ciror00 | 0:5e7248732177 | 24 | { |
ciror00 | 0:5e7248732177 | 25 | time_t epochSeconds; |
ciror00 | 0:5e7248732177 | 26 | epochSeconds = time(NULL); |
ciror00 | 0:5e7248732177 | 27 | return ctime(&epochSeconds); |
ciror00 | 0:5e7248732177 | 28 | } |
ciror00 | 0:5e7248732177 | 29 | |
ciror00 | 0:5e7248732177 | 30 | void dateAndTimeWrite( int year, int month, int day, |
ciror00 | 0:5e7248732177 | 31 | int hour, int minute, int second ) |
ciror00 | 0:5e7248732177 | 32 | { |
ciror00 | 0:5e7248732177 | 33 | struct tm rtcTime; |
ciror00 | 0:5e7248732177 | 34 | |
ciror00 | 0:5e7248732177 | 35 | rtcTime.tm_year = year - 1900; |
ciror00 | 0:5e7248732177 | 36 | rtcTime.tm_mon = month - 1; |
ciror00 | 0:5e7248732177 | 37 | rtcTime.tm_mday = day; |
ciror00 | 0:5e7248732177 | 38 | rtcTime.tm_hour = hour; |
ciror00 | 0:5e7248732177 | 39 | rtcTime.tm_min = minute; |
ciror00 | 0:5e7248732177 | 40 | rtcTime.tm_sec = second; |
ciror00 | 0:5e7248732177 | 41 | |
ciror00 | 0:5e7248732177 | 42 | rtcTime.tm_isdst = -1; |
ciror00 | 0:5e7248732177 | 43 | |
ciror00 | 0:5e7248732177 | 44 | set_time( mktime( &rtcTime ) ); |
ciror00 | 0:5e7248732177 | 45 | } |
ciror00 | 0:5e7248732177 | 46 | |
ciror00 | 0:5e7248732177 | 47 | //=====[Implementations of private functions]================================== |
ciror00 | 0:5e7248732177 | 48 |