Subject | Re: GMT time in Firebird |
---|---|
Author | Adam |
Post date | 2008-09-03T23:56:44Z |
--- In firebird-support@yahoogroups.com, Lester Caine <lester@...> wrote:
I already mentioned this work around/hack as an option in a previous
reply to Timothy. It *may* be an option if the server serves no other
purpose. I am glad that this work around is sufficient for you, but
for many it is not.
The clocks on all OSes supported by Firebird use UTC *natively*, and
only convert to a local representation upon request. In Windows for
example, GetLocalTime is internally a wrapper around GetSystemTime and
SystemTimeToTzSpecificLocalTime.
In terms of achieving the functionality, if you use Windows and
Delphi, you can write your own UDF using instructions on:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_howto2
The particular method you will need looks like:
function GetSystemTime : TDateTime;
var
st : TSYSTEMTIME;
begin
Windows.GetSystemTime(st);
Result := SystemTimeToDateTime(st);
end;
In a couple of minutes you can have the functionality for your Windows
installs anyway.
Adam
>server, I
> Adam wrote:
> > --- In firebird-support@yahoogroups.com, Lester Caine <lester@> wrote:
> >> Adam wrote:
> >>> --- In firebird-support@yahoogroups.com, "Timothy Madden"
> >>> <terminatorul@> wrote:
> >>>> Hello
> >>>>
> >>>> Is there a way to get or deduce GMT time from the Firebird
> >>> meanservers so they
> >>>> with SQL commands ?
> >>> Not directly. You can write / find a UDF to achieve the same thing,
> >>> but that is obviously harder if supporting multiple platforms.
> >>>
> >>> It is in the tracker as an enhancement request.
> >>> http://tracker.firebirdsql.org/browse/CORE-909
> >> The trick currently is to SET the local time on a server to UTC so
> > that all
> >> the times saved are UTC.
> >
> > A trick made much harder when a trigger like
> >
> > CREATE TRIGGER FOO_BU FOR FOO
> > ACTIVE BEFORE UPDATE POSITION 0
> > BEGIN
> > NEW.CHANGED_AT = CURRENT_TIMESTAMP;
> > END
> >
> > Sets the timestamp to the local time as seen by the server.
>
> That is the point - you set the local time *TO* UTC on all the
> all use the same clock ;)Lester,
I already mentioned this work around/hack as an option in a previous
reply to Timothy. It *may* be an option if the server serves no other
purpose. I am glad that this work around is sufficient for you, but
for many it is not.
The clocks on all OSes supported by Firebird use UTC *natively*, and
only convert to a local representation upon request. In Windows for
example, GetLocalTime is internally a wrapper around GetSystemTime and
SystemTimeToTzSpecificLocalTime.
In terms of achieving the functionality, if you use Windows and
Delphi, you can write your own UDF using instructions on:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_howto2
The particular method you will need looks like:
function GetSystemTime : TDateTime;
var
st : TSYSTEMTIME;
begin
Windows.GetSystemTime(st);
Result := SystemTimeToDateTime(st);
end;
In a couple of minutes you can have the functionality for your Windows
installs anyway.
Adam