ctime2l.txt
资源名称:DOS系统的源代码.rar [点击查看]
上传用户:xiaoan1112
上传日期:2013-04-11
资源大小:19621k
文件大小:2k
源码类别:
操作系统开发
开发平台:
Visual C++
- SUMMARY ctime2l ctime2tm date2l
- #include <time.h>
- #include <tools.h>
- long ctime2l(p)
- char * p;
- struct tm *ctime2tm(p)
- char *p;
- long date2l(year, month, day, hour, min, sec)
- int year, month, day, hour, min, sec;
- DESCRIPTION
- These functions provide the "inverse" of the C library time routines.
- ctime2l takes a strings in the formats
- Mon Jan 12 10:03:55 1986n
- Mon Jan 12 10:03:55 1986
- representing a local time and and returns a long that is the number of
- seconds elapsed since 00:00:00 Jan 1, 1970, Greenwich Mean Time. This is
- the inverse of the C library function ctime.
- ctime2tm takes a string in the above format, and returns a structure tm.
- date2l takes a date and returns a long that is the number of seconds elapsed
- since 00:00:00 Jan 1, 1970, Greenwich Mean Time. year is the actual year,
- e.g. 1986, NOT 86. month is 1 to 12, NOT 0 to 11.
- The string format may end with ' ' or 'n' ' '.
- RETURN VALUE
- IMPLEMENTATION
- SEE ALSO
- C library time functions
- NOTE
- EXAMPLE
- #include <time.h>
- #include <tools.h>
- main(c, v)
- int c;
- char **v;
- {
- long ltime;
- struct tm *ptm;
- char *p;
- printf("ltime = time(NULL): %ldn", (ltime = time(NULL)));
- printf("p = ctime(ltime): %s", (p = ctime(<ime)));
- ptm = localtime(<ime);
- printf("ptm = localtime(<ime)n");
- printf("wday:%d year:%d mon:%d mday:%d yday:%d ",
- ptm->tm_wday, ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_yday);
- printf("hour:%d min:%d sec:%d isdst:%dn",
- ptm->tm_hour, ptm->tm_min, ptm->tm_sec, ptm->tm_isdst);
- printf("ctime2l(p): %ldn", ctime2l(p));
- ptm = ctime2tm(p);
- printf("ptm = ctime2tm(p)n");
- printf("wday:%d year:%d mon:%d mday:%d yday:%d ",
- ptm->tm_wday, ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_yday);
- printf("hour:%d min:%d sec:%d isdst:%dn",
- ptm->tm_hour, ptm->tm_min, ptm->tm_sec, ptm->tm_isdst);
- printf("date2l(%d, %d, %d, %d, %d, %d): %ldn",
- ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,
- ptm->tm_hour, ptm->tm_min, ptm->tm_sec,
- date2l(ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday,
- ptm->tm_hour, ptm->tm_min, ptm->tm_sec));
- }