about summary refs log tree commit diff
path: root/src/libstddjb/localtmn_scan.c
blob: c9d4d19931a25d593df412882b9e6b0974321dc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ISC license. */

#include <sys/types.h>
#include <skalibs/uint32.h>
#include <skalibs/djbtime.h>

size_t localtmn_scan (char const *s, localtmn_t *l)
{
  localtmn_t m ;
  size_t n = localtm_scan(s, &m.tm) ;
  if (!n) return 0 ;
  s += n ;
  if (*s++ != '.') m.nano = 0 ;
  else
  {
    register size_t b = uint32_scan(s, &m.nano) ;
    if (!b) return 0 ;
    n += b ;
  }
  *l = m ;
  return n ;
}