summaryrefslogtreecommitdiff
path: root/src/libstddjb/ltm64_from_localtm.c
blob: 78e59a4cf218b0bfb7bb927090c09a948b5fd005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <errno.h>
#include <time.h>
#include <skalibs/uint64.h>
#include <skalibs/tai.h>
#include <skalibs/djbtime.h>

int ltm64_from_localtm (uint64_t *uu, struct tm const *l)
{
  struct tm ll = *l ;
  time_t u = mktime(&ll) ;
  if (u == (time_t)-1) return (errno = EINVAL, 0) ;
  *uu = TAI_MAGIC + u ;
  return 1 ;
}