skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

localtm_fmt.c (492B)


      1 /* ISC license. */
      2 
      3 #include <time.h>
      4 #include <skalibs/types.h>
      5 #include <skalibs/djbtime.h>
      6 
      7 size_t localtm_fmt (char *s, struct tm const *l)
      8 {
      9   char *p = s ;
     10   p += uint_fmt(p, 1900 + l->tm_year) ; *p++ = '-' ;
     11   uint0_fmt(p, 1 + l->tm_mon, 2) ; p += 2 ; *p++ = '-' ;
     12   uint0_fmt(p, l->tm_mday, 2) ; p += 2 ; *p++ = ' ' ;
     13   uint0_fmt(p, l->tm_hour, 2) ; p += 2 ; *p++ = ':' ;
     14   uint0_fmt(p, l->tm_min, 2) ; p += 2 ; *p++ = ':' ;
     15   uint0_fmt(p, l->tm_sec, 2) ; p += 2 ;
     16   return p - s ;
     17 }