Branch: Tag:

2013-05-28

2013-05-28 10:13:08 by Henrik Grubbström (Grubba) <grubba@grubba.org>

System.TM: Fixed year offset in create().

Also fixes a leak of the timezone string if create() is called
multiple times.

Also fixes Autodoc mk II markup in several places.

484:    RETURN 1;    }    -  /*! Create a new @[TM] initialized from a unix time_t. +  /*! @decl void create(int t) +  *! Create a new @[TM] initialized from a unix time_t.    *! The timezone will always be UTC when using this function.    */    PIKEFUN void create( int _t )
494:    Pike_error("time out of range\n");    }    -  /*! Construct a new TM, all fields will be set to 0. */ +  /*! @decl void create() +  *! Construct a new TM, all fields will be set to 0. +  */    PIKEFUN void create( )    {    memset( &THIS->t, 0, sizeof( struct tm ) );
503:    THIS->modified = 1;    }    -  /*! Construct a new time using the given values. +  /*! @decl void create( int year, int(0..11) mon, int(1..31) mday, @ +  *! int(0..24) hour, int(0..59) min, int(0..59) sec, @ +  *! string|void timezone ) +  *! Construct a new time using the given values.    *! Slightly faster than setting them individually.    */    PIKEFUN void create( int year, int(0..11) mon, int(1..31) mday,
512:    {    struct tm *t = &THIS->t;    t->tm_isdst = -1; -  t->tm_year = year; +  t->tm_year = year - 1900;    t->tm_mon = mon;    t->tm_mday = mday;    t->tm_hour = hour;    t->tm_min = min;    t->tm_sec = sec; -  +  if (THIS->set_zone) { +  free_string(THIS->set_zone); +  THIS->set_zone = NULL; +  }    if( !timezone ) /* gmtime. */    t->tm_zone = "UTC";    else    { -  timezone->refs++; +  add_ref(timezone);    THIS->set_zone = timezone;    t->tm_zone = timezone->str;    }