回文章列表
作者Dopin.bbs@bbs.bsd.com.tw (code 抓來慢慢摸) 看板: installbbs
標題Re: <轉錄/Local Save> 三篇關於 date_stamp 實作
時間亞特蘭提斯 (2010/02/12 Fri 12:35:34)
※ 引述《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       
文章選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻