|
|
| version 1.24, 2002/03/29 10:26:00 | version 1.27, 2002/04/18 10:50:59 |
|---|---|
| Line 13 | Line 13 |
| #include "pa_vdate.h" | #include "pa_vdate.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| // defines | |
| #define DATE_CLASS_NAME "date" | |
| // class | // class |
| class MDate : public Methoded { | class MDate : public Methoded { |
| Line 47 static void _create(Request& r, const St | Line 43 static void _create(Request& r, const St |
| VDate *vdate=static_cast<VDate *>(r.self); | VDate *vdate=static_cast<VDate *>(r.self); |
| time_t t; | time_t t; |
| if(params->size()==1) // ^set(float days) | if(params->size()==1) { // ^set(float days) |
| t=(time_t)(params->as_double(0, "float days must be double", r)*SECS_PER_DAY); | t=(time_t)(params->as_double(0, "float days must be double", r)*SECS_PER_DAY); |
| else if(params->size()>=2) { // ^set(y;m;d[;h[;m[;s]]]) | if(t<0 || !localtime(&t)) |
| throw Exception(0, | |
| &method_name, | |
| "invalid datetime"); | |
| } else if(params->size()>=2) { // ^set(y;m;d[;h[;m[;s]]]) | |
| tm tmIn={0}; | tm tmIn={0}; |
| tmIn.tm_isdst=-1; | tmIn.tm_isdst=-1; |
| int year=params->as_int(0, "year must be int", r); | int year=params->as_int(0, "year must be int", r); |
| Line 87 static void _sql_string(Request& r, cons | Line 87 static void _sql_string(Request& r, cons |
| string.APPEND_CLEAN(buf, size, | string.APPEND_CLEAN(buf, size, |
| method_name.origin().file, | method_name.origin().file, |
| method_name.origin().line); | method_name.origin().line); |
| Value& result=*new(pool) VString(string); | r.write_assign_lang(string); |
| r.write_assign_lang(result); | |
| } | } |
| Line 267 static void _calendar(Request& r, const | Line 266 static void _calendar(Request& r, const |
| table=fill_week_days(r, method_name, params, rus); | table=fill_week_days(r, method_name, params, rus); |
| VTable& result=*new(pool) VTable(pool, table); | VTable& result=*new(pool) VTable(pool, table); |
| result.set_name(method_name); | |
| r.write_no_lang(result); | r.write_no_lang(result); |
| } | } |
| // constructor | // constructor |
| MDate::MDate(Pool& apool) : Methoded(apool) { | MDate::MDate(Pool& apool) : Methoded(apool, "date") { |
| set_name(*NEW String(pool(), DATE_CLASS_NAME)); | |
| // ^now[] | // ^now[] |
| add_native_method("now", Method::CT_DYNAMIC, _now, 0, 1); | add_native_method("now", Method::CT_DYNAMIC, _now, 0, 1); |