Branch: Tag:

2014-09-29

2014-09-29 14:18:14 by Martin Nilsson <nilsson@opera.com>

Support initialization from calendar object.

962:    int tag = 23;    constant type_name = "UTCTime";    -  this_program init(int|string t) +  this_program init(int|string|Calendar.ISO_UTC.Second t)    {    if(intp(t))    set_posix([int]t); -  +  else if(objectp(t)) +  set_posix([object(Calendar.ISO_UTC.Second)]t);    else    value = [string]t;    }    -  //! +     this_program set_posix(int t)    { -  object second = Calendar.ISO_UTC.Second(t); +  return set_posix(Calendar.ISO_UTC.Second(t)); +  }    -  +  //! +  variant this_program set_posix(Calendar.ISO_UTC.Second second) +  { +     // RFC 2459 4.1.2.5.1:    //    // Where YY is greater than or equal to 50, the year shall be
1021:    // states that fractions shouldn't have trailing zeroes, and should    // be completely removed int the ".0" case.    -  //! +     this_program set_posix(int t)    { -  object second = Calendar.ISO_UTC.Second(t); +  return set_posix(Calendar.ISO_UTC.Second(t)); +  } +  +  //! +  variant this_program set_posix(Calendar.ISO_UTC.Second second) +  {    value = sprintf("%04d%02d%02d%02d%02d%02dZ",    [int]second->year_no(),    [int]second->month_no(),