Forum OpenACS Q&A: How do I use the ref-timezone pgsql functions?

Since receiving advice on timezones a couple of days ago I have been mingling a bit with some scripts. I loaded all timezone data and rules, only now I don't really know how to make use of the pgsql functions to get the data back out. I searched the OpenACS 4.5 dirs for code using the timezone__ functions, but only found the following code:

select to_char(timezone__utc_to_local(timezone__get_id(:tz), to_date(:time_value, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS');

and:

select to_char(timezone__local_to_utc(timezone__get_id(:tz), to_date(:time_value, 'YYYY-MM-DD HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS');

and:

select ( (current_time - timezone__local_to_utc (:system_timezone, current_time)) * 24 )

I tried using them from the postges command line, but didn't succeed in making them work, just got some errors:

bcuni=# select to_char(timezone__utc_to_local(timezone__get_id('-050000'),
bcuni(# to_date('2002-10-10 22:12:14', 'YYYY-MM-DD HH24:MI:SS')),
'YYYY-MM-DD HH24:MI:SS');
ERROR:  Function 'timezone__utc_to_local(int4, date)' does not exist
        Unable to identify a function that satisfies the given
argument types
        You may need to add explicit typecasts
bcuni=# 

I basically have two variables:

- user's timezone (for example "-05:00")
- time to send reminder (for example "2002-12-12 14:00:00")

I need to switch back and forth between user's local time and server's local time in order to send out the reminder at the correct time and date. I take the functions above do just that.

Can anyone provide me with help and/or some code example showing me how to use the functions in my code?

Thanks, Simon