OSDN Git Service

addid library source 20140221
[zither/ds-zither.git] / sources / lib / libms / utime_getr.c
1 #include<stdio.h>
2 #include<time.h>
3
4 #include "almemsys.h"
5
6 /* UNIX時間から時間日付等を返す (thread safe) */
7
8 int utime_getr(time_t tt, char ch)
9 {
10 time_t t;
11 struct tm tmbuf;
12
13 t = tt;
14 localtime_r(&t, &tmbuf);
15
16 switch(ch){
17   case 'y': return(tmbuf.tm_year + 1900);
18   case 'm': return(tmbuf.tm_mon + 1);
19   case 'd': return(tmbuf.tm_mday);
20   case 'w': return(tmbuf.tm_wday);
21   case 'h': return(tmbuf.tm_hour);
22   case 'i': return(tmbuf.tm_min);
23   case 's': return(tmbuf.tm_sec);
24   default : return(0); break;
25   }
26
27 return -1;
28 }
29
30
31