X-Git-Url: http://wpitchoune.net/gitweb/?p=psensor-pkg-debian.git;a=blobdiff_plain;f=src%2Flib%2Fptime.c;h=05ca1a1b198f42f70fe81c2afed70d0f668ac7dc;hp=2c06c7cadd0cee96b9a666d6f5ea6b333b504fb0;hb=3361fda8735c65887a859c9faf287cb105ae6bc8;hpb=f59206913efca168851e1a3f57b1b0f5a50495ec diff --git a/src/lib/ptime.c b/src/lib/ptime.c index 2c06c7c..05ca1a1 100644 --- a/src/lib/ptime.c +++ b/src/lib/ptime.c @@ -1,27 +1,27 @@ /* - Copyright (C) 2010-2014 jeanfi@gmail.com - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program 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 - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA + * Copyright (C) 2010-2016 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA */ #include #include #include -const int P_TIME_VER = 2; +const int P_TIME_VER = 3; static const int ISO8601_TIME_LENGTH = 19; /* YYYY-MM-DDThh:mm:ss */ static const int ISO8601_DATE_LENGTH = 10; /* YYYY-MM-DD */ @@ -54,12 +54,11 @@ char *tm_to_ISO8601_date(struct tm *tm) str = malloc(ISO8601_DATE_LENGTH + 1); - if (strftime(str, ISO8601_DATE_LENGTH + 1, "%F", tm)) { + if (strftime(str, ISO8601_DATE_LENGTH + 1, "%F", tm)) return str; - } else { - free(str); - return NULL; - } + + free(str); + return NULL; } char *tm_to_ISO8601_time(struct tm *tm) @@ -68,15 +67,14 @@ char *tm_to_ISO8601_time(struct tm *tm) str = malloc(ISO8601_TIME_LENGTH + 1); - if (strftime(str, ISO8601_TIME_LENGTH + 1, "%FT%T", tm)) { + if (strftime(str, ISO8601_TIME_LENGTH + 1, "%FT%T", tm)) return str; - } else { - free(str); - return NULL; - } + + free(str); + return NULL; } -char *get_current_ISO8601_time() +char *get_current_ISO8601_time(void) { time_t t;