|
|
| version 1.13, 2001/11/12 10:32:24 | version 1.20, 2002/03/26 08:51:00 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b date parser class. | Parser: @b date parser class. |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| $Id$ | $Id$ |
| */ | */ |
| Line 37 static void _now(Request& r, const Strin | Line 37 static void _now(Request& r, const Strin |
| vdate->set_time(time(0)); | vdate->set_time(time(0)); |
| } | } |
| static void _set(Request& r, const String& method_name, MethodParams *params) { | static void _create(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); |
| Line 76 static void _sql_string(Request& r, cons | Line 76 static void _sql_string(Request& r, cons |
| int size=1+ 4+1+2+1+2 +1+ 2+1+2+1+2 +1 +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", localtime(&time)); |
| String& string=*new(pool) String(pool); | String& string=*new(pool) String(pool); |
| string.APPEND_CLEAN(buf, size, | string.APPEND_CLEAN(buf, size, |
| Line 130 static void _roll(Request& r, const Stri | Line 130 static void _roll(Request& r, const Stri |
| tmOut->tm_hour=tmSaved.tm_hour; | tmOut->tm_hour=tmSaved.tm_hour; |
| tmOut->tm_min=tmSaved.tm_min; | tmOut->tm_min=tmSaved.tm_min; |
| tmOut->tm_sec=tmSaved.tm_sec; | tmOut->tm_sec=tmSaved.tm_sec; |
| tmOut->tm_isdst=-1; | |
| { | { |
| time_t t=mktime(tmOut); | time_t t=mktime(tmOut); |
| if(t<0) | if(t<0) |
| Line 183 static Table *fill_week_days(Request& r, | Line 184 static Table *fill_week_days(Request& r, |
| const String& method_name, MethodParams *params, bool rus){ | const String& method_name, MethodParams *params, bool rus){ |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Array& columns=*new(pool) Array(pool, 4); | Array& columns=*new(pool) Array(pool, 4); |
| columns+=new(pool) String(pool, "year"); | |
| columns+=new(pool) String(pool, "month"); | |
| columns+=new(pool) String(pool, "day"); | |
| columns+=new(pool) String(pool, "weekday"); | |
| Table *result=new(pool) Table(pool, &method_name, &columns); | Table *result=new(pool) Table(pool, &method_name, &columns); |
| int year=params->as_int(1, "year must be int", r); | int year=params->as_int(1, "year must be int", r); |
| Line 259 MDate::MDate(Pool& apool) : Methoded(apo | Line 264 MDate::MDate(Pool& apool) : Methoded(apo |
| add_native_method("now", Method::CT_DYNAMIC, _now, 0, 0); | add_native_method("now", Method::CT_DYNAMIC, _now, 0, 0); |
| // ^set(float days) | // ^set(float days) |
| add_native_method("set", Method::CT_DYNAMIC, _set, 1, 6); | add_native_method("create", Method::CT_DYNAMIC, _create, 1, 6); |
| add_native_method("set", Method::CT_DYNAMIC, _create, 1, 6); | |
| // ^sql-string[] | // ^sql-string[] |
| add_native_method("sql-string", Method::CT_DYNAMIC, _sql_string, 0, 0); | add_native_method("sql-string", Method::CT_DYNAMIC, _sql_string, 0, 0); |