candle1113
14th February 2002, 22:43
In Java there is a method toLocaleString() which will convert a date/time string from UTC/GMT time to the local system time. Is there a comparable function/method in BaaN script?
I am accessing the job history records and they are stored in GMT time and I need to easily convert them to Eastern Standard Time (taking daylight savings time into account when needed).

lbencic
14th February 2002, 23:14
In Baan 5 there is the predefined functions:
utc.to.local (long utc, ref long local_days, ref long local_time)
local.to.utc(long local_days, long local_time, ref long utc)
Where local days = Number of days since 1-1-01 and
local time = number of seconds since 00:00.

UTC functionality is new to Baan 5.

These functions do not exist in Baan 4. But, in 4, you can use the functions:
long date.to.num(long yearno, long monthno, long month_day)
long num.to.date(long dayno, ref long yearno, ref long monthno, ref long month_dayno)
to do some similar workings with Baan 4's stored date number (not in UTC format).

Kees de Jong
14th February 2002, 23:49
Other usefull functions are:

utc.to.date ( long utc, ref long yearno, ref long monthno, ref long month_dayno, ref long hours, ref long minutes, ref long seconds )

This converts a UTC long format value to the corresponding year, month, day, and so on, in local time.

---

utc.to.week ( long utc, ref long week_dayno, ref long year_dayno, ref long weekno, ref long hours, ref long minutes, ref long seconds [, ref long yearno] )

This converts a UTC long format value to the corresponding day of the week, day of the year, week of the year, and so on, in local time.

Arguments
- dayno: The UTC long format value.
- week_dayno: The day of the week. This depends on which day is defined as the first day of the week in the user data settings in the data dictionary.
- year_dayno: The day number in the year.
- weekno: The week number in the year.
- hours, minutes, seconds: The time of day.
- yearno: The year number. This argument is optional.

---

utc.to.input ( long lvalue, const string format() )

This converts a UTC long format value to an input date string or an input time string (in local time). The format specified determines whether the function returns a date string or a time string.

Arguments
- lvalue: A UTC long format value.
- format: The format for the input string. For a UTC date, use the substitution symbols %uxxx[,lang] or %u(format). For a UTC time, use the substitution symbols %Uxxx[,lang] or %U(format).

---

And of course the other way around:
date.to.utc()
week.to.utc()
input.to.utc()

Regards,
Baan5user

candle1113
19th February 2002, 02:12
Unfortunately, we are only using BaaN4c4 so I guess I will have to make my own home-grown UTC to local time functions.

I appreciate everyones help.

NPRao
19th February 2002, 02:31
In addition you can also use the function -

Syntax

long set.time.zone( string time_zone(50) )

Description

This sets the local time zone at run time.

Return values

0 success
-1 error

Context

Bshell function.

candle1113
19th February 2002, 18:58
I finally found this functon in Knowledge Quest (which I believe is for Baan 4)
long UTC.TO.LOCAL ( ref long local_days,
ref long local_time,
long utc_days,
long utc_time )

The brief explanation of this function is:
This function converts the Coordinated Universal Time to the local time. The 'utc_days' argument must be specified as the number of days since 01-01-0001. The utc time must be specified in seconds. The return value of this function can be zero (OK) or 1 (error).

I'm still not sure how I would use this to convert the date field ttaad511.sdts (domain ttdate) and time field ttaad511.stis (domain ttdate) in the job managment table ttaad511 from UTC to local date and time on a report.

Anybody have any input?

evesely
19th February 2002, 19:23
In your report script, define the variables local_date and local_time (or something similar) as externs. Then in the appropriate layout's before.layout subsection of your report, call:
utc.to.local(local_date, local_time, ttaad512.sdts, ttaad512.stis)

You can then put local_date and local_time in your layout on the report.

lbencic
19th February 2002, 19:34
Well, I'm sure you figured this out by now, but the UTC functions have been ported to Baan IV now. Sorry for the mis-info.

The IV format allows for UTC Date and UTC Time in separate fields, where in Baan V, they are one field. So, the syntax for the functions is different in IV than what we listed for you. The Knowlwedge Quest seems most up to date!