|
|
| version 1.90, 2012/03/06 07:41:49 | version 1.93, 2015/04/08 18:08:52 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b date parser class. | Parser: @b date parser class. |
| Copyright (c) 2001-2012 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2012 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) |
| */ | */ |
| static const char * const IDENT_DATE_C="$Date$"; | |
| #include "classes.h" | #include "classes.h" |
| #include "pa_vmethod_frame.h" | #include "pa_vmethod_frame.h" |
| Line 15 static const char * const IDENT_DATE_C=" | Line 13 static const char * const IDENT_DATE_C=" |
| #include "pa_vdate.h" | #include "pa_vdate.h" |
| #include "pa_vtable.h" | #include "pa_vtable.h" |
| volatile const char * IDENT_DATE_C="$Id$" IDENT_PA_VDATE_H; | |
| // class | // class |
| class MDate: public Methoded { | class MDate: public Methoded { |
| Line 112 static int to_tm_year(int iyear) { | Line 112 static int to_tm_year(int iyear) { |
| tm tmIn; memset(&tmIn, 0, sizeof(tmIn)); | tm tmIn; memset(&tmIn, 0, sizeof(tmIn)); |
| tmIn.tm_isdst=-1; | tmIn.tm_isdst=-1; |
| if(!month) | if(!month) { |
| if(min) { | if(min) { |
| year=mday=0; // HH:MM | year=mday=0; // HH:MM |
| time_t t=time(0); | time_t t=time(0); |
| Line 122 static int to_tm_year(int iyear) { | Line 122 static int to_tm_year(int iyear) { |
| tmIn.tm_mday=tmNow->tm_mday; | tmIn.tm_mday=tmNow->tm_mday; |
| goto date_part_set; | goto date_part_set; |
| } else | } else |
| hour=min=sec=msec=0; // not YYYY- & not HH: = just YYYY | hour=min=sec=msec=0; // not YYYY- & not HH: = just YYYY |
| } | |
| tmIn.tm_year=to_tm_year(pa_atoi(year)); | tmIn.tm_year=to_tm_year(pa_atoi(year)); |
| tmIn.tm_mon=month?pa_atoi(month)-1:0; | tmIn.tm_mon=month?pa_atoi(month)-1:0; |
| tmIn.tm_mday=mday?pa_atoi(mday):1; | tmIn.tm_mday=mday?pa_atoi(mday):1; |
| Line 138 static void _create(Request& r, MethodPa | Line 139 static void _create(Request& r, MethodPa |
| VDate& vdate=GET_SELF(r, VDate); | VDate& vdate=GET_SELF(r, VDate); |
| if(params.count()==1){ | if(params.count()==1){ |
| if(const String* sdate=params[0].get_string()){ // ^create[2002-04-25 18:14:00] ^create[18:14:00] | if(params[0].is_string()){ // ^create[2002-04-25 18:14:00] ^create[18:14:00] |
| vdate.set_time(cstr_to_time_t(sdate->cstrm())); | vdate.set_time(cstr_to_time_t(params[0].get_string()->cstrm())); |
| } else { // ^create(float days) or ^create[date object] | } else { // ^create(float days) or ^create[date object] |
| time_t t=(time_t)round(params.as_double(0, "float days must be double", r)*SECS_PER_DAY); | time_t t=(time_t)round(params.as_double(0, "float days must be double", r)*SECS_PER_DAY); |
| if(t<0 || !localtime(&t)) | if(t<0 || !localtime(&t)) |