看板SetupBBS
标 题Re: <转录/Local Save> 三篇关於 date_stamp 实作
发信站亚特兰提斯 (Fri Feb 12 12:35:34 2010)
转信站ptt!news.ntu!news.au!zoonews.ee.ntu!News.leobbs.net!Atlantis
※ 引述《[email protected] ( )》之铭言:
: #include <time.h>
: time_t mktime(struct tm *timeptr);
: 这样不就得到timestamp?
: 然後丢给difftime就出来了不是?
呃 我要说声抱歉 看了 m 兄的提点我才去男人一下 :)
#include <stdio.h>
#include <time.h>
int main(void) {
struct tm time_a;
time_t now;
time_a.tm_year = 2010 - 1900;
time_a.tm_mon = 03;
time_a.tm_mday = 25;
time_a.tm_min = 0;
time_a.tm_sec = 0;
now = mktime(&time_a);
printf("%d %s\n", (int)now, ctime(&now));
return 0;
}
Derived from the POSIX.1-1988 standard and ANSI C standard.
实在惭愧 早期没注意到这个函式 1998 年我已经不太碰新东西了 ^^;;;
感谢指正 :) 再次感恩 Orz
不过也因为阿呆所以把加加减减给实作出来 /.\;;;
--
Origin:
Atlantis DN:
bbs.bsd.com.tw IP :
203.70.65.27 ST:
atlantis