OSDN Git Service

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