suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

caldate_scan.c (564B)


      1 #include <tai/caldate.h>
      2 
      3 unsigned int caldate_scan(char *s, struct caldate *cd)
      4 {
      5   int sign = 1;
      6   char *t = s;
      7   unsigned long z;
      8   unsigned long c;
      9 
     10   if (*t == '-') { ++t; sign = -1; }
     11   z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
     12   cd->year = z * sign;
     13 
     14   if (*t++ != '-') return 0;
     15   z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
     16   cd->month = z;
     17 
     18   if (*t++ != '-') return 0;
     19   z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
     20   cd->day = z;
     21 
     22   return t - s;
     23 }