--- parser3/src/classes/date.C 2016/10/04 13:23:45 1.105 +++ parser3/src/classes/date.C 2023/11/26 16:02:41 1.115 @@ -1,8 +1,8 @@ /** @file Parser: @b date parser class. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "classes.h" @@ -12,8 +12,9 @@ #include "pa_vdouble.h" #include "pa_vdate.h" #include "pa_vtable.h" +#include "pa_vbool.h" -volatile const char * IDENT_DATE_C="$Id: date.C,v 1.105 2016/10/04 13:23:45 moko Exp $" IDENT_PA_VDATE_H; +volatile const char * IDENT_DATE_C="$Id: date.C,v 1.115 2023/11/26 16:02:41 moko Exp $" IDENT_PA_VDATE_H; // class @@ -57,12 +58,16 @@ static void _now(Request& r, MethodParam vdate.set_time(t); } -static void _today(Request& r, MethodParams&) { +static void _today(Request& r, MethodParams& params) { VDate& vdate=GET_SELF(r, VDate); time_t t=time(0); tm today=*localtime(&t); + + if (params.count() == 1) // ^today(offset) + today.tm_mday += params.as_int(0, "offset must be int", r); + today.tm_hour=0; today.tm_min=0; today.tm_sec=0; @@ -188,7 +193,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 +240,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<