X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flp.c;h=fe4c019403c43de03c4c035fe12ccf2b6ca1af66;hb=06f5d6b7432d639ff3721d56f2c89b7d5b6cb963;hp=bd9ba5d95fd1aa11162e51e2e975ba8eeb4145f0;hpb=a9435991d03d0bd9e81d6cb6003013bec4b2e6e9;p=ppastats.git diff --git a/src/lp.c b/src/lp.c index bd9ba5d..fe4c019 100644 --- a/src/lp.c +++ b/src/lp.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 jeanfi@gmail.com + * Copyright (C) 2011-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 @@ -24,6 +24,27 @@ #include "list.h" #include "lp.h" +char *time_to_str(time_t t) +{ + char *str; + struct tm *tm; + size_t ret; + + tm = localtime(&t); + + if (!tm) + return NULL; + + str = malloc(strlen("YYYY-MM-DDThh:mm:ss") + 1); + ret = strftime(str, strlen("YYYY-MM-DDThh:mm:ss") + 1, "%FT%T", tm); + + if (ret) + return str; + + free(str); + return NULL; +} + struct distro_series *distro_series_new(const char *name, const char *version, const char *title, @@ -69,7 +90,9 @@ struct bpph *bpph_new(const char *binary_package_name, const char *binary_package_version, const char *distro_arch_series_link, const char *self_link, - int architecture_specific) + const char *status, + int architecture_specific, + time_t date_created) { struct bpph *h; @@ -80,8 +103,8 @@ struct bpph *bpph_new(const char *binary_package_name, h->distro_arch_series_link = strdup(distro_arch_series_link); h->self_link = strdup(self_link); h->architecture_specific = architecture_specific; - h->status = NULL; - h->date_created.tm_isdst = -1; + h->status = strdup(status); + h->date_created = date_created; return h; }