--- parser3/src/classes/date.C 2016/03/31 21:46:19 1.103 +++ parser3/src/classes/date.C 2020/12/15 17:10:27 1.112 @@ -1,7 +1,7 @@ /** @file 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 (http://paf.design.ru) */ @@ -13,7 +13,7 @@ #include "pa_vdate.h" #include "pa_vtable.h" -volatile const char * IDENT_DATE_C="$Id: date.C,v 1.103 2016/03/31 21:46:19 moko Exp $" IDENT_PA_VDATE_H; +volatile const char * IDENT_DATE_C="$Id: date.C,v 1.112 2020/12/15 17:10:27 moko Exp $" IDENT_PA_VDATE_H; // class @@ -70,7 +70,7 @@ static void _today(Request& r, MethodPar vdate.set_tm(today); } -static int to_year(int iyear) { +int to_year(int iyear) { if(iyear<0 || iyear>9999) throw Exception(DATE_RANGE_EXCEPTION_TYPE, 0, "year '%d' is out of range 0..9999", iyear); return iyear-1900; @@ -188,7 +188,7 @@ tm cstr_to_time_t(char *cstr, const char char *cur=cstr; 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); if(delim != ':' || delim == ':' && strlen(year) >=4 ){ @@ -235,9 +235,9 @@ tm cstr_to_time_t(char *cstr, const char tmIn.tm_mday=tmNow->tm_mday; } - tmIn.tm_hour=hour?pa_atoi(hour):0; - tmIn.tm_min=min?pa_atoi(min):0; - tmIn.tm_sec=sec?pa_atoi(sec):0; + tmIn.tm_hour=pa_atoi(hour); + tmIn.tm_min=pa_atoi(min); + tmIn.tm_sec=pa_atoi(sec); //tmIn.tm_[msec<get("ms")){ - if(r.process_to_value(*vshow_ms).as_bool()) + if(r.process(*vshow_ms).as_bool()) format=VDate::iso_string_type(format|VDate::iso_string_ms); valid_options++; } if(Value* vshow_colon=options->get("colon")){ - if(!r.process_to_value(*vshow_colon).as_bool()) + if(!r.process(*vshow_colon).as_bool()) format=VDate::iso_string_type(format|VDate::iso_string_no_colon); valid_options++; } if(Value* vshow_z=options->get("z")){ - if(!r.process_to_value(*vshow_z).as_bool()) + if(!r.process(*vshow_z).as_bool()) format=VDate::iso_string_type(format|VDate::iso_string_no_z); valid_options++; } @@ -324,7 +324,7 @@ static void _iso_string(Request& r, Meth 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) { @@ -476,7 +476,7 @@ static Table& fill_week_days(Request& r, } static void _calendar(Request& r, MethodParams& params) { - const String& what=params.as_string(0, "format must be strig"); + const String& what=params.as_string(0, "format must be string"); bool rus=false; if(what=="rus") rus=true; @@ -491,7 +491,7 @@ static void _calendar(Request& r, Method else // 1+3 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) { @@ -499,7 +499,7 @@ static void _unix_timestamp(Request& r, if(params.count()==0) { // ^date.unix-timestamp[] - r.write_no_lang(*new VDouble((double)vdate.get_time())); + r.write(*new VDouble((double)vdate.get_time())); } else { if(vdate.get_time()) throw Exception(PARSER_RUNTIME, 0, "date object already constructed"); @@ -522,7 +522,7 @@ static void _last_day(Request& r, Method // ^date.lastday[] 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