|
|
| version 1.2, 2001/07/07 17:59:02 | version 1.7, 2001/09/21 14:46:09 |
|---|---|
| Line 4 | Line 4 |
| Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) | Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf) |
| $Id$ | |
| */ | */ |
| static const char *RCSId="$Id$"; | static const char *RCSId="$Id$"; |
| Line 51 static void _set(Request& r, const Strin | Line 49 static void _set(Request& r, const Strin |
| int year=params->as_int(0, r); | int year=params->as_int(0, r); |
| if(year<70) // 0..69 -> 100..169 [2000..2069] | if(year<70) // 0..69 -> 100..169 [2000..2069] |
| year+=100; | year+=100; |
| if(year>=1900) | |
| year-=1900; | |
| tmIn.tm_year=year; | tmIn.tm_year=year; |
| tmIn.tm_mon=params->as_int(1, r)-1; | tmIn.tm_mon=params->as_int(1, r)-1; |
| tmIn.tm_mday=params->as_int(2, r); | tmIn.tm_mday=params->as_int(2, r); |
| Line 69 static void _set(Request& r, const Strin | Line 69 static void _set(Request& r, const Strin |
| vdate->set_time(time); | vdate->set_time(time); |
| } | } |
| static void _string(Request& r, const String& method_name, MethodParams *) { | static void _sql_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=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", gmtime(&time)); |
| Value& result=*new(pool) VString(*new(pool) String(pool, buf, size)); | String& string=*new(pool) String(pool); |
| 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(result); |
| } | } |
| Line 130 MDate::MDate(Pool& apool) : Methoded(apo | Line 134 MDate::MDate(Pool& apool) : Methoded(apo |
| // ^set(float days) | // ^set(float days) |
| add_native_method("set", Method::CT_DYNAMIC, _set, 1, 6); | add_native_method("set", Method::CT_DYNAMIC, _set, 1, 6); |
| // ^string[] | // ^sql-string[] |
| add_native_method("string", Method::CT_DYNAMIC, _string, 0, 0); | add_native_method("sql-string", Method::CT_DYNAMIC, _sql_string, 0, 0); |
| // ^roll(year|month|day;+/- 1) | // ^roll(year|month|day;+/- 1) |
| add_native_method("roll", Method::CT_DYNAMIC, _roll, 2, 2); | add_native_method("roll", Method::CT_DYNAMIC, _roll, 2, 2); |