|
|
| version 1.1, 2001/07/07 16:38:01 | version 1.2, 2001/07/07 17:59:02 |
|---|---|
| Line 72 static void _set(Request& r, const Strin | Line 72 static void _set(Request& r, const Strin |
| static void _string(Request& r, const String& method_name, MethodParams *) { | static void _string(Request& r, const String& method_name, MethodParams *) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VDate *vdate=static_cast<VDate *>(r.self); | VDate *vdate=static_cast<VDate *>(r.self); |
| int size=4+1+2+1+2 +1+ 2+1+2+1+2 +1; | int size=1+ 4+1+2+1+2 +1+ 2+1+2+1+2 +1 +1; |
| char *buf=(char *)pool.malloc(size); | char *buf=(char *)pool.malloc(size); |
| time_t time=vdate->get_time(); | time_t time=vdate->get_time(); |
| size=strftime(buf, size, "%Y-%m-%d %H:%M:%S", gmtime(&time)); | size=strftime(buf, size, "'%Y-%m-%d %H:%M:%S'", gmtime(&time)); |
| Value& result=*new(pool) VString(*new(pool) String(pool, buf, size)); | Value& result=*new(pool) VString(*new(pool) String(pool, buf, size)); |
| r.write_assign_lang(result); | r.write_assign_lang(result); |
| } | } |
| static int isLeap(int year) { | |
| return !( | |
| (year % 4) || ((year % 400) && !(year % 100)) | |
| ); | |
| } | |
| static int getMonthDays(int year, int month) { | |
| int monthDays[]={ | |
| 31, | |
| isLeap(year) ? 29 : 28, | |
| 31, | |
| 30, | |
| 31, | |
| 30, | |
| 31, | |
| 31, | |
| 30, | |
| 31, | |
| 30, | |
| 31 | |
| }; | |
| return monthDays[month]; | |
| } | |
| static void _roll(Request& r, const String& method_name, MethodParams *params) { | static void _roll(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| VDate *vdate=static_cast<VDate *>(r.self); | VDate *vdate=static_cast<VDate *>(r.self); |