|
|
| version 1.106, 2016/10/06 20:38:36 | version 1.112, 2020/12/15 17:10:27 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b date parser class. | Parser: @b date parser class. |
| Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 188 tm cstr_to_time_t(char *cstr, const char | Line 188 tm cstr_to_time_t(char *cstr, const char |
| char *cur=cstr; | char *cur=cstr; |
| const char *year, *month, *mday; | const char *year, *month, *mday; |
| const char *hour, *min, *sec, *msec; | const char *hour, *min, *sec, *msec PA_ATTR_UNUSED; |
| year=skip_number(&cur, "-:", &delim); | year=skip_number(&cur, "-:", &delim); |
| if(delim != ':' || delim == ':' && strlen(year) >=4 ){ | if(delim != ':' || delim == ':' && strlen(year) >=4 ){ |
| Line 235 tm cstr_to_time_t(char *cstr, const char | Line 235 tm cstr_to_time_t(char *cstr, const char |
| tmIn.tm_mday=tmNow->tm_mday; | tmIn.tm_mday=tmNow->tm_mday; |
| } | } |
| tmIn.tm_hour=hour?pa_atoi(hour):0; | tmIn.tm_hour=pa_atoi(hour); |
| tmIn.tm_min=min?pa_atoi(min):0; | tmIn.tm_min=pa_atoi(min); |
| tmIn.tm_sec=sec?pa_atoi(sec):0; | tmIn.tm_sec=pa_atoi(sec); |
| //tmIn.tm_[msec<<no such, waits reimplementation of the class]=f(msec); | //tmIn.tm_[msec<<no such, waits reimplementation of the class]=f(msec); |
| return tmIn; | return tmIn; |
| Line 288 static void _sql_string(Request& r, Meth | Line 288 static void _sql_string(Request& r, Meth |
| throw Exception(PARSER_RUNTIME, &what, "'type' must be 'date', 'time' or 'datetime'"); | throw Exception(PARSER_RUNTIME, &what, "'type' must be 'date', 'time' or 'datetime'"); |
| } | } |
| r.write_assign_lang(*vdate.get_sql_string(format)); | r.write(*vdate.get_sql_string(format)); |
| } | } |
| static void _gmt_string(Request& r, MethodParams&) { | static void _gmt_string(Request& r, MethodParams&) { |
| VDate& vdate=GET_SELF(r, VDate); | VDate& vdate=GET_SELF(r, VDate); |
| r.write_assign_lang(*vdate.get_gmt_string()); | r.write(*vdate.get_gmt_string()); |
| } | } |
| static void _iso_string(Request& r, MethodParams& params) { | static void _iso_string(Request& r, MethodParams& params) { |
| Line 324 static void _iso_string(Request& r, Meth | Line 324 static void _iso_string(Request& r, Meth |
| throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); | throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); |
| } | } |
| r.write_assign_lang(*vdate.get_iso_string(format)); | r.write(*vdate.get_iso_string(format)); |
| } | } |
| static void _roll(Request& r, MethodParams& params) { | static void _roll(Request& r, MethodParams& params) { |
| Line 491 static void _calendar(Request& r, Method | Line 491 static void _calendar(Request& r, Method |
| else // 1+3 | else // 1+3 |
| table=&fill_week_days(r, params, rus); | table=&fill_week_days(r, params, rus); |
| r.write_no_lang(*new VTable(table)); | r.write(*new VTable(table)); |
| } | } |
| static void _unix_timestamp(Request& r, MethodParams& params) { | static void _unix_timestamp(Request& r, MethodParams& params) { |
| Line 499 static void _unix_timestamp(Request& r, | Line 499 static void _unix_timestamp(Request& r, |
| if(params.count()==0) { | if(params.count()==0) { |
| // ^date.unix-timestamp[] | // ^date.unix-timestamp[] |
| r.write_no_lang(*new VDouble((double)vdate.get_time())); | r.write(*new VDouble((double)vdate.get_time())); |
| } else { | } else { |
| if(vdate.get_time()) | if(vdate.get_time()) |
| throw Exception(PARSER_RUNTIME, 0, "date object already constructed"); | throw Exception(PARSER_RUNTIME, 0, "date object already constructed"); |
| Line 522 static void _last_day(Request& r, Method | Line 522 static void _last_day(Request& r, Method |
| // ^date.lastday[] | // ^date.lastday[] |
| tmIn=GET_SELF(r, VDate).get_tm(); | tmIn=GET_SELF(r, VDate).get_tm(); |
| } | } |
| r.write_no_lang(*new VInt(VDate::getMonthDays(tmIn.tm_year, tmIn.tm_mon))); | r.write(*new VInt(VDate::getMonthDays(tmIn.tm_year, tmIn.tm_mon))); |
| } | } |
| // constructor | // constructor |