return ::writev(socket,vector,count);
}
+/* this is cut and pasted from dietlibc, gratefully copied! */
+static int isleap(int year) {
+ /* every fourth year is a leap year except for century years that are
+ * not divisible by 400. */
+ return (!(year%4) && ((year%100) || !(year%400)));
+}
+
+time_t Utility::timegm(struct tm *const t)
+{
+ const static short spm[13] = /* days per month -- nonleap! */
+ { 0,
+ (31),
+ (31+28),
+ (31+28+31),
+ (31+28+31+30),
+ (31+28+31+30+31),
+ (31+28+31+30+31+30),
+ (31+28+31+30+31+30+31),
+ (31+28+31+30+31+30+31+31),
+ (31+28+31+30+31+30+31+31+30),
+ (31+28+31+30+31+30+31+31+30+31),
+ (31+28+31+30+31+30+31+31+30+31+30),
+ (31+28+31+30+31+30+31+31+30+31+30+31),
+ };
+
+ time_t day;
+ time_t i;
+ time_t years = t->tm_year - 70;
+
+ if (t->tm_sec>60) { t->tm_min += t->tm_sec/60; t->tm_sec%=60; }
+ if (t->tm_min>60) { t->tm_hour += t->tm_min/60; t->tm_min%=60; }
+ if (t->tm_hour>60) { t->tm_mday += t->tm_hour/60; t->tm_hour%=60; }
+ if (t->tm_mon>12) { t->tm_year += t->tm_mon/12; t->tm_mon%=12; }
+
+ while (t->tm_mday>spm[1+t->tm_mon]) {
+ if (t->tm_mon==1 && isleap(t->tm_year+1900)) {
+ if (t->tm_mon==31+29) break;
+ --t->tm_mday;
+ }
+ t->tm_mday-=spm[t->tm_mon];
+ ++t->tm_mon;
+ if (t->tm_mon>11) { t->tm_mon=0; ++t->tm_year; }
+ }
+
+ if (t->tm_year < 70)
+ return (time_t) -1;
+ /* Days since 1970 is 365 * number of years + number of leap years since 1970 */
+ day = years * 365 + (years + 1) / 4;
+
+ /* After 2100 we have to substract 3 leap years for every 400 years
+ This is not intuitive. Most mktime implementations do not support
+ dates after 2059, anyway, so we might leave this out for it's
+ bloat. */
+ if ((years -= 131) >= 0) {
+ years /= 100;
+ day -= (years >> 2) * 3 + 1;
+ if ((years &= 3) == 3) years--;
+ day -= years;
+ }
+
+ day += t->tm_yday = spm [t->tm_mon] + t->tm_mday-1 + ( isleap (t->tm_year+1900) & (t->tm_mon > 1) );
+
+ /* day is now the number of days since 'Jan 1 1970' */
+ i = 7;
+ t->tm_wday = (day + 4) % i; /* Sunday=0, Monday=1, ..., Saturday=6 */
+
+ i = 24;
+ day *= i;
+ i = 60;
+ return ((day + t->tm_hour) * i + t->tm_min) * i + t->tm_sec;
+}
+