--- parser3/src/classes/date.C 2002/03/29 10:26:00 1.24 +++ parser3/src/classes/date.C 2002/04/18 10:50:59 1.27 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: date.C,v 1.24 2002/03/29 10:26:00 paf Exp $ + $Id: date.C,v 1.27 2002/04/18 10:50:59 paf Exp $ */ #include "classes.h" @@ -13,10 +13,6 @@ #include "pa_vdate.h" #include "pa_vtable.h" -// defines - -#define DATE_CLASS_NAME "date" - // class class MDate : public Methoded { @@ -47,9 +43,13 @@ static void _create(Request& r, const St VDate *vdate=static_cast(r.self); 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); - 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}; tmIn.tm_isdst=-1; int year=params->as_int(0, "year must be int", r); @@ -87,8 +87,7 @@ static void _sql_string(Request& r, cons string.APPEND_CLEAN(buf, size, method_name.origin().file, method_name.origin().line); - Value& result=*new(pool) VString(string); - r.write_assign_lang(result); + r.write_assign_lang(string); } @@ -267,16 +266,12 @@ static void _calendar(Request& r, const table=fill_week_days(r, method_name, params, rus); VTable& result=*new(pool) VTable(pool, table); - result.set_name(method_name); r.write_no_lang(result); } // constructor -MDate::MDate(Pool& apool) : Methoded(apool) { - set_name(*NEW String(pool(), DATE_CLASS_NAME)); - - +MDate::MDate(Pool& apool) : Methoded(apool, "date") { // ^now[] add_native_method("now", Method::CT_DYNAMIC, _now, 0, 1);