📄 time.c
字号:
/* ---------------------------------------------------------------------------- CFL - A C Foundation Library Copyright (C) 1994-2003 Mark A Lindner This file is part of CFL. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ---------------------------------------------------------------------------- $Log: time.c,v $ Revision 1.1 2003/03/03 08:20:08 markl Initial checkin (clean compile on Solaris & OS X) ----------------------------------------------------------------------------*//* Feature test switches */#include "config.h"#define _POSIX_C_SOURCE 199506L#ifdef linux#define _XOPEN_SOURCE 500#endif/* System headers */#include <time.h>/* Local headers */#include "cfl/defs.h"/* Functions */c_bool_t C_time_format(time_t t, char *buf, size_t bufsz, const char *format) { time_t t1; struct tm t2; t1 = (t ? t : time(NULL)); (void)localtime_r(&t1, &t2); return((strftime(buf, bufsz, format, &t2) > 0) ? TRUE : FALSE); }/* */time_t C_time_parse(const char *buf, const char *format) { struct tm t; if(! strptime(buf, format, &t)) return((time_t)0); return(mktime(&t)); }/* end of source file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -