ktime.c
最終更新:2009/10/10
001: /* ktime.c 002: * 時刻処理の例 003: * TIME: apr_time_now / apr_time_ctime / apr_time_gmt / apr_time_lt / apr_strftime 004: */ 005: 006: #include "apr_general.h" 007: #include "apr_file_io.h" 008: 009: #include "apr_time.h" 010: 011: #include "mystab.h" 012: 013: int apr_my_main (int ac, char **av, apr_file_t * astdin, apr_file_t * astdout, apr_file_t * astderr, apr_pool_t * pool) { 014: char buf[1024]; 015: 016: 017: /* apr_time_now / apr_time_ctime / apr_time_gmt / apr_time_lt / apr_strftime 018: * INCLUDE apr_time.h 019: * LIB libapr-1.lib 020: */ 021: { 022: /* 現在時刻をバッファに保存 */ 023: 024: apr_ctime(buf, apr_time_now()); 025: apr_file_printf(astdout, "CTIME: [%s]\n", buf); 026: 027: { 028: apr_time_exp_t tm; 029: int retsize=0; 030: 031: /* GMT タイムゾーンで現在時刻を取得 */ 032: 033: apr_time_exp_gmt(&tm, apr_time_now()); 034: 035: /* 時刻のフォーマット */ 036: 037: apr_strftime(buf, &retsize, 1024, "%Y/%m/%d %H:%M:%S", &tm); 038: apr_file_printf(astdout, "GMT: [%s] [%dbytes]\n", buf, retsize); 039: 040: /* ローカルタイムゾーンで現在時刻を取得 */ 041: 042: apr_time_exp_lt(&tm, apr_time_now()); 043: 044: /* 時刻のフォーマット */ 045: 046: apr_strftime(buf, &retsize, 1024, "%Y/%m/%d %H:%M:%S", &tm); 047: apr_file_printf(astdout, "LOCAL: [%s] [%dbytes]\n", buf, retsize); 048: } 049: } 050: 051: apr_file_printf(astdout, "\ndone.\n"); 052: 053: return 0; /* 正常終了 */ 054: } 055:
KAKU PROJECT (2009) |