Re: <轉錄/Local Save> 三篇關於 date_stamp 實作
※ 引述《mosquito520.bbs@ptt.cc ( )》之銘言:
: #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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):