13 #ifndef TIMEZONE_INLINE_HELPERS_H
14 #define TIMEZONE_INLINE_HELPERS_H
29 if(a.size()<s)
return 0;
31 if(((
signed char)a[0])<0)r=-1;
34 r|=(
unsigned char)a[i];
45 if((year%400)==0)
return true;
46 if((year%100)==0)
return false;
47 if((year%4)==0)
return true;
61 for(
int y=1970;y<year;y++)
65 for(
int y=1969;y>=year;y--)
92 inline int pmod(qint64 num,
int mod)
100 inline qint64
fdiv(qint64 num,qint64 div)
105 if(num>0)
return num/div;
125 return pmod(daySinceEpoch+4,7);
157 inline void stamp2Time(qint64 stamp,quint8&h,quint8&m,quint8&s)
159 stamp=
pmod(stamp,SecondsPerDay);
184 if(off<31){m=1;d=off+1;
return;}
else off-=31;
185 if(off<28){m=2;d=off+1;
return;}
else off-=28;
188 else{m=2;d=29;
return;}
190 if(off<31){m=3;d=off+1;
return;}
else off-=31;
191 if(off<30){m=4;d=off+1;
return;}
else off-=30;
192 if(off<31){m=5;d=off+1;
return;}
else off-=31;
193 if(off<30){m=6;d=off+1;
return;}
else off-=30;
194 if(off<31){m=7;d=off+1;
return;}
else off-=31;
195 if(off<31){m=8;d=off+1;
return;}
else off-=31;
196 if(off<30){m=9;d=off+1;
return;}
else off-=30;
197 if(off<31){m=10;d=off+1;
return;}
else off-=31;
198 if(off<30){m=11;d=off+1;
return;}
else off-=30;
199 if(off<31){m=12;d=off+1;
return;}
else off-=31;
205 inline void stamp2Date(qint64 off,qint16&y,quint8&m,quint8&d)
207 qint64 de=
fdiv(off,SecondsPerDay);
218 r+=h*3600 + m*60 + s;
228 inline qint64
dateTime2stamp(
int y,quint8 mon,quint8 day,quint8 hr,quint8 min,quint8 s)
int pmod(qint64 num, int mod)
Definition: tzhelp.h:92
bool isLeapYear(int year)
Definition: tzhelp.h:43
qint64 daysSinceEpoch(int year, int month=1, int day=1)
Definition: tzhelp.h:56
qint64 fdiv(qint64 num, qint64 div)
Definition: tzhelp.h:100
qint64 firstWeekDayOf(int year, int month, int wday)
Definition: tzhelp.h:130
static const qint64 SecondsPerDay
Definition: tzhelp.h:22
int weekDaySinceEpoch(qint64 daySinceEpoch)
Definition: tzhelp.h:123
void offset2Date(qint64 off, qint16 &y, quint8 &m, quint8 &d)
Definition: tzhelp.h:166
void stamp2Date(qint64 off, qint16 &y, quint8 &m, quint8 &d)
Definition: tzhelp.h:205
qint64 dateTime2stamp(qint64 days, quint8 h, quint8 m, quint8 s)
Definition: tzhelp.h:215
qint64 lastWeekDayOf(int year, int month, int wday)
Definition: tzhelp.h:142
qint64 decodeInt(const QByteArray &a, int s=4)
Definition: tzhelp.h:27
qint64 decodeInt64(const QByteArray &a)
Definition: tzhelp.h:40
int weekDayOf(int year, int month=1, int day=1)
Definition: tzhelp.h:116
void stamp2Time(qint64 stamp, quint8 &h, quint8 &m, quint8 &s)
Definition: tzhelp.h:157