suitcase

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

caltime_fmt.c (805B)


      1 #include <tai/caldate.h>
      2 #include <tai/caltime.h>
      3 
      4 unsigned int caltime_fmt(char *s, struct caltime *ct)
      5 {
      6   unsigned int result;
      7   long x;
      8 
      9   result = caldate_fmt(s,&ct->date);
     10 
     11   if (s) {
     12     s += result;
     13   
     14     x = ct->hour;
     15     s[0] = ' ';
     16     s[2] = '0' + (x % 10); x /= 10;
     17     s[1] = '0' + (x % 10);
     18     s += 3;
     19   
     20     x = ct->minute;
     21     s[0] = ':';
     22     s[2] = '0' + (x % 10); x /= 10;
     23     s[1] = '0' + (x % 10);
     24     s += 3;
     25     
     26     x = ct->second;
     27     s[0] = ':';
     28     s[2] = '0' + (x % 10); x /= 10;
     29     s[1] = '0' + (x % 10);
     30     s += 3;
     31 
     32     s[0] = ' ';
     33     x = ct->offset;
     34     if (x < 0) { s[1] = '-'; x = -x; } else s[1] = '+';
     35 
     36     s[5] = '0' + (x % 10); x /= 10;
     37     s[4] = '0' + (x % 6); x /= 6;
     38     s[3] = '0' + (x % 10); x /= 10;
     39     s[2] = '0' + (x % 10);
     40   }
     41 
     42   return result + 15;
     43 }