Diff for /parser3/src/classes/date.C between versions 1.43 and 1.45.2.1

version 1.43, 2003/04/09 10:58:43 version 1.45.2.1, 2003/09/01 12:27:27
Line 145  static void _sql_string(Request& r, cons Line 145  static void _sql_string(Request& r, cons
         r.write_assign_lang(string);          r.write_assign_lang(string);
 }  }
   
   
 static void _roll(Request& r, const String& method_name, MethodParams *params) {  static void _roll(Request& r, const String& method_name, MethodParams *params) {
         Pool& pool=r.pool();          Pool& pool=r.pool();
         VDate *vdate=static_cast<VDate *>(r.get_self());          VDate *vdate=static_cast<VDate *>(r.get_self());
Line 158  static void _roll(Request& r, const Stri Line 157  static void _roll(Request& r, const Stri
         if(what=="year") offset=&oyear;          if(what=="year") offset=&oyear;
         else if(what=="month") offset=&omonth;          else if(what=="month") offset=&omonth;
         else if(what=="day") offset=&oday;          else if(what=="day") offset=&oday;
         else          else if(what=="TZ") {
                   const String& argument_tz=params->as_string(1, "'TZ' must be string");
                   vdate->set_tz(&argument_tz);
                   return;
           } else
                 throw Exception("parser.runtime",                  throw Exception("parser.runtime",
                         &what,                          &what,
                         "must be year|month|day");                          "must be year|month|day|TZ");
                   
         *offset=params->as_int(1, "offset must be int", r);          *offset=params->as_int(1, "offset must be int", r);
   
Line 169  static void _roll(Request& r, const Stri Line 172  static void _roll(Request& r, const Stri
         tm tmIn=*localtime(&self_time);          tm tmIn=*localtime(&self_time);
         tm tmSaved=tmIn;          tm tmSaved=tmIn;
         int adjust_day=0;          int adjust_day=0;
         time_t t_changed_date;          time_t changed_time;
         while(true) {          while(true) {
                 tmIn.tm_year+=oyear;                  tmIn.tm_year+=oyear;
                 tmIn.tm_mon+=omonth;                  tmIn.tm_mon+=omonth;
Line 177  static void _roll(Request& r, const Stri Line 180  static void _roll(Request& r, const Stri
                 tmIn.tm_hour=24/2;                   tmIn.tm_hour=24/2; 
                 tmIn.tm_min=0;                  tmIn.tm_min=0;
                 tmIn.tm_sec=0;                  tmIn.tm_sec=0;
                 int saved_mon=tmIn.tm_mon;                  int saved_mon=(tmIn.tm_mon+12*100)%12; // crossing year boundary backwards
                 t_changed_date=mktime/*normalizetime*/(&tmIn);                  changed_time=mktime/*normalizetime*/(&tmIn);
                 if(t_changed_date<0)                  if(changed_time<0)
                         throw Exception(0,                          throw Exception(0,
                                 &method_name,                                  &method_name,
                                 "bad resulting time (rolled out of valid date range)");                                  "bad resulting time (rolled out of valid date range)");
Line 195  static void _roll(Request& r, const Stri Line 198  static void _roll(Request& r, const Stri
                         break;                                            break;                  
         }          }
   
         tm *tmOut=localtime(&t_changed_date);          tm *tmOut=localtime(&changed_time);
         if(!tmOut)          if(!tmOut)
                 throw Exception(0,                  throw Exception(0,
                         &method_name,                          &method_name,
                         "bad resulting time (seconds from epoch=%d)", t_changed_date);                          "bad resulting time (seconds from epoch=%d)", changed_time);
       
         tmOut->tm_hour=tmSaved.tm_hour;          tmOut->tm_hour=tmSaved.tm_hour;
         tmOut->tm_min=tmSaved.tm_min;          tmOut->tm_min=tmSaved.tm_min;
         tmOut->tm_sec=tmSaved.tm_sec;          tmOut->tm_sec=tmSaved.tm_sec;
Line 226  static void _roll(Request& r, const Stri Line 229  static void _roll(Request& r, const Stri
 }  }
   
 static Table *fill_month_days(Request& r,   static Table *fill_month_days(Request& r, 
                                                           const String& method_name, MethodParams *params, bool rus){                                const String& method_name, MethodParams *params, bool rus){
         Pool& pool=r.pool();          Pool& pool=r.pool();
         Table *result=new(pool) Table(pool, *date_calendar_table_template);          Table::Action_options table_options;
           Table *result=new(pool) Table(pool, *date_calendar_table_template, table_options);
   
         int year=params->as_int(1, "year must be int", r);          int year=params->as_int(1, "year must be int", r);
         int month=max(1, min(params->as_int(2, "month must be int", r), 12)) -1;          int month=max(1, min(params->as_int(2, "month must be int", r), 12)) -1;

Removed from v.1.43  
changed lines
  Added in v.1.45.2.1


E-mail: