time.c

来自「CFL是Unix下的通用抽象库,以简化Unix下的系统软件开发,CFL库中包含几」· C语言 代码 · 共 75 行

C
75
字号
/* ----------------------------------------------------------------------------   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 + =
减小字号Ctrl + -
显示快捷键?