/* ktime.c * 時刻処理の例 * TIME: apr_time_now / apr_time_ctime / apr_time_gmt / apr_time_lt / apr_strftime */ #include "apr_general.h" #include "apr_file_io.h" #include "apr_time.h" #include "mystab.h" int apr_my_main (int ac, char **av, apr_file_t * astdin, apr_file_t * astdout, apr_file_t * astderr, apr_pool_t * pool) { char buf[1024]; /* apr_time_now / apr_time_ctime / apr_time_gmt / apr_time_lt / apr_strftime * INCLUDE apr_time.h * LIB libapr-1.lib */ { /* 現在時刻をバッファに保存 */ apr_ctime(buf, apr_time_now()); apr_file_printf(astdout, "CTIME: [%s]\n", buf); { apr_time_exp_t tm; int retsize=0; /* GMT タイムゾーンで現在時刻を取得 */ apr_time_exp_gmt(&tm, apr_time_now()); /* 時刻のフォーマット */ apr_strftime(buf, &retsize, 1024, "%Y/%m/%d %H:%M:%S", &tm); apr_file_printf(astdout, "GMT: [%s] [%dbytes]\n", buf, retsize); /* ローカルタイムゾーンで現在時刻を取得 */ apr_time_exp_lt(&tm, apr_time_now()); /* 時刻のフォーマット */ apr_strftime(buf, &retsize, 1024, "%Y/%m/%d %H:%M:%S", &tm); apr_file_printf(astdout, "LOCAL: [%s] [%dbytes]\n", buf, retsize); } } apr_file_printf(astdout, "\ndone.\n"); return 0; /* 正常終了 */ }