rduncan10
19th June 2007, 22:45
We had a custom session that added a range of dates to the job calendar. This worked under older versions of Baan, but since we upgraded to Baan IVc4, it does not handle the times very well
This is because the table (ttaad507) was changed to use UTC. I've been reading through many threads here and on the WIKI about time conversion, but I still cannot get the functions that covnert dates to times to work.
The user inputs a range of dates, and the time (in its own field using tctmhs). I need to covnert this integer to its equivalent in UTC, but I can't get this to work.
Here is what I've tried:
This version adds the hours offset from GMT to the time integer. This actually worked until it got to the end of daylight savings time, then the results were off by an hour.
declaration:
table tttaad507 | MRP Calendar
extern domain tcdate date.f
extern domain tcdate date.t
extern domain tcdate sel.date
extern domain tctmhs run.tm
choice.cont.process:
on.choice:
sel.date = date.f
while sel.date <= date.t
add.to.calendar()
sel.date = sel.date + 1
endwhile
functions:
function add.to.calendar()
{
long time.offset = 400 | offset from GMT
db.retry.point()
select ttaad507.*
from ttaad507 for update
where ttaad507._index1 = {:calc, :sel.date, :run.tm}
order by ttaad507._index1
selectempty
ttaad507.calc = calc
ttaad507.date = sel.date
ttaad507.time = run.time + time.offset db.insert(tttaad507, db.retry)
commit.transaction()
selectdo
endselect
}
This version tries to use the local.to.utc() function, but the results seem random.
| ... other code as above ... |
function add.to.calendar()
{
long utc.days
long utc.time
long loc.time
long ret
loc.time = run.tm * 3600 | Convert entered time to seconds
ret = local.to.utc(utc.days, utc.time, sel.date, loc.time)
db.retry.point()
select ttaad507.*
from ttaad507 for update
where ttaad507._index1 = {:calc, :sel.date, :run.tm}
order by ttaad507._index1
selectempty
ttaad507.calc = calc
ttaad507.date = sel.date
ttaad507.time = utc.time db.insert(tttaad507, db.retry)
commit.transaction()
selectdo
endselect
}
Thanks,
RD
This is because the table (ttaad507) was changed to use UTC. I've been reading through many threads here and on the WIKI about time conversion, but I still cannot get the functions that covnert dates to times to work.
The user inputs a range of dates, and the time (in its own field using tctmhs). I need to covnert this integer to its equivalent in UTC, but I can't get this to work.
Here is what I've tried:
This version adds the hours offset from GMT to the time integer. This actually worked until it got to the end of daylight savings time, then the results were off by an hour.
declaration:
table tttaad507 | MRP Calendar
extern domain tcdate date.f
extern domain tcdate date.t
extern domain tcdate sel.date
extern domain tctmhs run.tm
choice.cont.process:
on.choice:
sel.date = date.f
while sel.date <= date.t
add.to.calendar()
sel.date = sel.date + 1
endwhile
functions:
function add.to.calendar()
{
long time.offset = 400 | offset from GMT
db.retry.point()
select ttaad507.*
from ttaad507 for update
where ttaad507._index1 = {:calc, :sel.date, :run.tm}
order by ttaad507._index1
selectempty
ttaad507.calc = calc
ttaad507.date = sel.date
ttaad507.time = run.time + time.offset db.insert(tttaad507, db.retry)
commit.transaction()
selectdo
endselect
}
This version tries to use the local.to.utc() function, but the results seem random.
| ... other code as above ... |
function add.to.calendar()
{
long utc.days
long utc.time
long loc.time
long ret
loc.time = run.tm * 3600 | Convert entered time to seconds
ret = local.to.utc(utc.days, utc.time, sel.date, loc.time)
db.retry.point()
select ttaad507.*
from ttaad507 for update
where ttaad507._index1 = {:calc, :sel.date, :run.tm}
order by ttaad507._index1
selectempty
ttaad507.calc = calc
ttaad507.date = sel.date
ttaad507.time = utc.time db.insert(tttaad507, db.retry)
commit.transaction()
selectdo
endselect
}
Thanks,
RD