--
-- timezone__add_rule/8
--
create or replace function timezone__add_rule(
  p_tz character varying,
  p_abbrev character varying,
  p_isdst_p integer,
  p_gmt_offset character varying,
  p_utc_start character varying,
  p_utc_end character varying,
  p_local_start character varying,
  p_local_end character varying
) returns int4 as $$

DECLARE
BEGIN
  insert into timezone_rules
    (tz_id, abbrev, utc_start, utc_end, local_start, local_end, gmt_offset, isdst_p)
  select timezone__get_id(p_tz), p_abbrev, rdbms_date(p_utc_start),
    rdbms_date(p_utc_end), rdbms_date(p_local_start),
    to_date(p_local_end),
    p_gmt_offset,
    case p_isdst_p when 0 then 'f' else 't'end;
END;
$$ language plpgsql;