time.h

Go to the documentation of this file.
00001 /* time.h */
00002 
00003 #ifndef __SYSTEM
00004 #include "routix/system.h"
00005 #endif
00006 
00007 #define CMOS_C          0x70
00008 #define CMOS_V          0x71
00009 
00010 
00011 #define CUR_SEC         0
00012 #define CUR_MIN         2
00013 #define CUR_HOUR        4
00014 #define CUR_DAYOFWEEK   6
00015 #define CUR_DAYOFMONTH  7
00016 #define CUR_MONTH       8
00017 #define CUR_YEAR        9
00018 #define STAT_REG_A      0xa
00019 #define STAT_REG_B      0xb     
00020 
00021 #define bcdtochar(valor)                (valor - 6 * (byte) (valor/16))
00022 #define chartobcd(valor)                (valor % 10 + ( ( (byte) valor / 10 ) << 4 ))
00023 
00024 #define get_hour()              bcdtochar(get_value(CUR_HOUR))
00025 #define get_min()               bcdtochar(get_value(CUR_MIN))
00026 #define get_sec()               bcdtochar(get_value(CUR_SEC))
00027 #define get_dayofweek()         bcdtochar(get_value(CUR_DAYOFWEEK))
00028 #define get_dayofmonth()        bcdtochar(get_value(CUR_DAYOFMONTH))
00029 #define get_month()             bcdtochar(get_value(CUR_MONTH))
00030 #define get_year()              bcdtochar(get_value(CUR_YEAR))
00031 #define get_stat_reg_a()        get_value(STAT_REG_A)
00032 #define get_stat_reg_b()        get_value(STAT_REG_B)
00033 
00034 #define set_hour(valor)         set_value(CUR_HOUR, chartobcd(valor))
00035 
00036 
00037 // Defines de funciones de tiempo
00038 #define ANIO_INICIO     70
00039 #define MES_INICIO      0
00040 #define DIA_INICIO      1
00041 
00042 #define SEC_PER_MIN             (60)
00043 #define SEC_PER_HOUR            (60 * SEC_PER_MIN)
00044 #define SEC_PER_DAY             (24 * SEC_PER_HOUR)
00045 #define SEC_PER_YEAR(anio)      ( ( 365 + es_bisiesto(anio) ) * SEC_PER_DAY )
00046 #define SEC_PER_MONTH(anio,mes) ( dias_por_mes[mes] + ( ( (mes == FEBRERO) && es_bisiesto(1900+anio) ) ? 1 : 0 ) ) * SEC_PER_DAY
00047 
00048 
00049 // Estructura tm
00050 struct tm {
00051      int   tm_sec;    /* seconds after the minute - [0, 61] */
00052                       /* for leap seconds */
00053      int   tm_min;    /* minutes after the hour - [0, 59] */
00054      int   tm_hour;   /* hour since midnight - [0, 23] */
00055      int   tm_mday;   /* day of the month - [1, 31] */
00056      int   tm_mon;    /* months since January - [0, 11] */
00057      int   tm_year;   /* years since 1900 */
00058      int   tm_wday;   /* days since Sunday - [0, 6] */
00059      int   tm_yday;   /* days since January 1 - [0, 365] */
00060      int   tm_isdst;  /* flag for alternate daylight savings time */
00061 };
00062 
00063 typedef int time_t;
00064 
00065 // Definimos los tipos
00066 struct tm *localtime(const time_t *clock);
00067 time_t mktime(struct tm *tm);
00068 int day_of_year(int anio, int mes, int dia);
00069 char *asctime(const struct tm *tm);
00070 
00071 inline void actualizar_reloj();
00072 int es_bisiesto(int year);
00073 
00074 
00075 

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6