initial commit
[pfinal.git] / Routix / src / tareas / timedeb.c
blob65686326a24835cc2723452f15067ecc8c04d385
1 /* timedeb.c */
3 /* Este archivo tiene como Ășnico fin realizar el debug de la
4 * libreria time.c */
6 #include "routix/time.h"
7 #include "routix/timer.h"
9 #ifndef __SYSTEM
10 #include "routix/system.h"
11 #endif
14 #define cmd(comando) ( ! strcmp(msg,comando) )
16 // Funciones
17 void dump_tm();
18 void bisiestos();
19 void local();
22 void time_debug(void) {
24 char msg[80];
25 while(1) {
26 kprintf("tmdebug > ");
27 gets(msg);
29 if ( cmd("exit") ) { return; }
30 else if ( cmd("dump") ) { dump_tm(); }
31 else if ( cmd("bis") ) { bisiestos(); }
32 else if ( cmd("tod") ) { kprintf("tod: %d\n",mktime( localtime(NULL) )); }
33 else if ( cmd("localtime") ) { local(); }
34 else if ( cmd("asctime") ) { asctime( localtime(NULL) ); }
35 else if ( cmd("jiffies") ) { kprintf("jiffies: %d\n",jiffies); }
36 else if ( cmd("excepcion") ) { dword *prueba=(dword *) 0xfffffff; *prueba=2; }
45 void dump_tm()
47 struct tm *tm;
49 tm = localtime(NULL);
51 kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
52 kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
53 kprintf(" tm_wday=%d\n tm_yday=%d",tm->tm_wday,tm->tm_yday);
57 void bisiestos()
59 int i,counter;
60 char msg[80];
62 gets(msg);
63 i=atoi(msg);
65 for ( counter=0; counter < 10; counter++,i++) {
66 if ( es_bisiesto(i) ) { kprintf("%d es bisiesto\n",i); }
67 else { kprintf("%d no es bisiesto\n",i); }
73 void local()
75 struct tm *tm;
76 time_t tod;
78 tod = mktime( localtime(NULL) );
81 tm = localtime(NULL);
83 kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
84 kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
85 kprintf(" tm_wday=%d\n",tm->tm_wday);
87 kprintf("\ntod: %d\n",tod);
89 tm = localtime(&tod);
91 kprintf(" tm_seg=%d\n tm_min=%d\n tm_hour=%d\n",tm->tm_sec,tm->tm_min,tm->tm_hour);
92 kprintf(" tm_mday=%d\n tm_mon=%d\n tm_year=%d\n",tm->tm_mday,tm->tm_mon,tm->tm_year);
93 kprintf(" tm_wday=%d\n",tm->tm_wday);