Diff for /parser3/src/classes/date.C between versions 1.47 and 1.52

version 1.47, 2003/10/30 12:46:23 version 1.52, 2003/11/07 13:59:21
Line 19  static const char* IDENT_DATE_C="$Date$" Line 19  static const char* IDENT_DATE_C="$Date$"
   
 class MDate: public Methoded {  class MDate: public Methoded {
 public: // VStateless_class  public: // VStateless_class
         Value* create_new_value() { return new VDate(0); }          Value* create_new_value(Pool& apool) { return new VDate(0); }
   
 public:  public:
         MDate();          MDate();
Line 168  static void _sql_string(Request& r, Meth Line 168  static void _sql_string(Request& r, Meth
         r.write_assign_lang(String(buf, size));          r.write_assign_lang(String(buf, size));
 }  }
   
   
 static void _roll(Request& r, MethodParams& params) {  static void _roll(Request& r, MethodParams& params) {
         VDate& vdate=GET_SELF(r, VDate);          VDate& vdate=GET_SELF(r, VDate);
   
Line 180  static void _roll(Request& r, MethodPara Line 179  static void _roll(Request& r, MethodPara
         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 375  static void _calendar(Request& r, Method Line 378  static void _calendar(Request& r, Method
         r.write_no_lang(*new VTable(table));          r.write_no_lang(*new VTable(table));
 }  }
   
   static void _unix_timestamp(Request& r, MethodParams& params) {
           VDate& vdate=GET_SELF(r, VDate);
   
           if(params.count()==0) { 
                   // ^date.unix-timestamp[]
                   r.write_no_lang(*new VInt((int)vdate.get_time()));
           } else {
                   if(vdate.get_time())
                           throw Exception(0,
                                   0,
                                   "date object already constructed");
   
                   // ^unix-timestamp(time_t)
                   time_t t=(time_t)params.as_int(0, "Unix timestamp must be integer", r);
   
                   vdate.set_time(t);
           }
   }
   
   
 // constructor  // constructor
   
 MDate::MDate(): Methoded("date") {  MDate::MDate(): Methoded("date") {
Line 396  MDate::MDate(): Methoded("date") { Line 419  MDate::MDate(): Methoded("date") {
         // ^date:calendar[week|weekeng;year;month;day] = table          // ^date:calendar[week|weekeng;year;month;day] = table
         add_native_method("calendar", Method::CT_STATIC, _calendar, 3, 4);          add_native_method("calendar", Method::CT_STATIC, _calendar, 3, 4);
   
   
           // ^unix-timestamp[]
           add_native_method("unix-timestamp", Method::CT_DYNAMIC, _unix_timestamp, 0, 1);
 }  }

Removed from v.1.47  
changed lines
  Added in v.1.52


E-mail: