Guido Ottaviani / Mbed 2 deprecated LeonardoMbos

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers time.c Source File

time.c

00001 /*
00002  *
00003  * NMEA library
00004  * URL: http://nmea.sourceforge.net
00005  * Author: Tim (xtimor@gmail.com)
00006  * Licence: http://www.gnu.org/licenses/lgpl.html
00007  * $Id: time.c 4 2007-08-27 13:11:03Z xtimor $
00008  *
00009  */
00010 
00011 /*! \file time.h */
00012 
00013 #include "nmea/time.h "
00014 
00015 #ifdef NMEA_WIN
00016 #   pragma warning(disable: 4201)
00017 #   pragma warning(disable: 4214)
00018 #   pragma warning(disable: 4115)
00019 #   include <windows.h>
00020 #   pragma warning(default: 4201)
00021 #   pragma warning(default: 4214)
00022 #   pragma warning(default: 4115)
00023 #else
00024 #   include <time.h >
00025 #endif
00026 
00027 #ifdef NMEA_WIN
00028 
00029 void nmea_time_now(nmeaTIME *stm)
00030 {
00031     SYSTEMTIME st;
00032 
00033     GetSystemTime(&st);
00034 
00035     stm->year = st.wYear - 1900;
00036     stm->mon = st.wMonth - 1;
00037     stm->day = st.wDay;
00038     stm->hour = st.wHour;
00039     stm->min = st.wMinute;
00040     stm->sec = st.wSecond;
00041     stm->hsec = st.wMilliseconds / 10;
00042 }
00043 
00044 #else /* NMEA_WIN */
00045 
00046 void nmea_time_now(nmeaTIME *stm)
00047 {
00048     time_t lt;
00049     struct tm *tt;
00050 
00051     time(&lt);
00052     tt = gmtime(&lt);
00053 
00054     stm->year = tt->tm_year;
00055     stm->mon = tt->tm_mon;
00056     stm->day = tt->tm_mday;
00057     stm->hour = tt->tm_hour;
00058     stm->min = tt->tm_min;
00059     stm->sec = tt->tm_sec;
00060     stm->hsec = 0;
00061 }
00062 
00063 #endif