Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert UTC ordinals to UTC 5-byte time

27 views
Skip to first unread message

Dave Higton

unread,
Dec 30, 2009, 4:13:22 PM12/30/09
to
How can one convert UTC ordinals to a 5-byte UTC time?

I can find a territory-dependent version, which implies a conversion
error during either DST or non-DST; but I can't find a way either to
specify UTC input to Territory_ConvertOrdinalsToTime, or to do a
conversion that is inherently UTC-to-UTC.

If anyone knows the trick, please tell me what it is.

Dave

Jonathan Graham Harston

unread,
Dec 31, 2009, 3:38:23 PM12/31/09
to
daveh...@dsl.pipex.com wrote:
> How can one convert UTC ordinals to a 5-byte UTC time?

In platform-independant BBC BASIC, use PROCDate_FromOrd() in the
Date library at http://mdfs.net/blib

Convert time and date to 5-byte centi-second count
==================================================
DEFPROCDate_FromOrd(mem%,d%,m%,y%,hr%,mn%,sc%,cs%)

On entry: mem%->five bytes of memory
day, month, year of the date
hours, minutes, seconds, centiseconds of the time
On exit: mem% to mem%+4 containes five-byte centisecond time since
00:00:00 on 1-Jan-1900.

Example:
DIM timebuf% 4
PROCDate_FromOrd(timebuf%, 7,1,1969, 00,30,00,00)

to get a certain personally interesting date-point.

Otherwise, for a RISC OS-only solution, you can use SWI
"Territory_ConvertOrdinalsToTime"

DIM utc% 4
DIM ord% 27
ord%!0=centisecond
ord%!4=seconds
ord%!8=minutes
ord%!12=hours
ord%!16=day
ord%!20=month
ord%!24=year
SYS "Territory_ConvertOrdinalsToTime", -1, utc%, ord%

but as you say, that converts local time, not to UTC, so does DST/NODST
conversion.

--
J.G.Harston - j...@arcade.demon.co.uk - mdfs.net/User/JGH
Whitby Yards Gazetteer - http://mdfs.net/Docs/Books/YofWhitby/Gazetteer

Dave Higton

unread,
Jan 1, 2010, 10:57:22 AM1/1/10
to
In message <091231...@arcade.demon.co.uk>

j...@arcade.demon.co.uk (Jonathan Graham Harston) wrote:

> daveh...@dsl.pipex.com wrote:
> > How can one convert UTC ordinals to a 5-byte UTC time?
>
> In platform-independant BBC BASIC, use PROCDate_FromOrd() in the
> Date library at http://mdfs.net/blib
>
> Convert time and date to 5-byte centi-second count
> ==================================================
> DEFPROCDate_FromOrd(mem%,d%,m%,y%,hr%,mn%,sc%,cs%)
>
> On entry: mem%->five bytes of memory
> day, month, year of the date
> hours, minutes, seconds, centiseconds of the time
> On exit: mem% to mem%+4 containes five-byte centisecond time since
> 00:00:00 on 1-Jan-1900.
>
> Example:
> DIM timebuf% 4
> PROCDate_FromOrd(timebuf%, 7,1,1969, 00,30,00,00)
>
> to get a certain personally interesting date-point.

OK, thanks for that.

> Otherwise, for a RISC OS-only solution, you can use SWI
> "Territory_ConvertOrdinalsToTime"
>
> DIM utc% 4
> DIM ord% 27
> ord%!0=centisecond
> ord%!4=seconds
> ord%!8=minutes
> ord%!12=hours
> ord%!16=day
> ord%!20=month
> ord%!24=year
> SYS "Territory_ConvertOrdinalsToTime", -1, utc%, ord%
>
> but as you say, that converts local time, not to UTC, so does DST/NODST
> conversion.

Yes. A curious omission from RISC OS. Worse than just DST/NODST,
if my app is used in a territory other than GMT or GMT - 1, the
above will add an even bigger error.

It would be neat if there were a Territory (perhaps 0?) representing
UTC, so that SYS "Territory_ConvertOrdinalsToTime" could be called
with that Territory and therefore always return the correct time.

Dave

Jean-Michel

unread,
Jan 2, 2010, 6:39:24 AM1/2/10
to
In message <091231...@arcade.demon.co.uk>
j...@arcade.demon.co.uk (Jonathan Graham Harston) wrote:

How did you do it, you predict the Iyonix date BUG ?

Jean-Michel


--
Jean-Michel BRUCK
jmc....@orange.fr
Europ�en Computer : RISC OS ( Iyonix pc 5.13 & RiscPc (Select))

Jeremy Nicoll - news posts

unread,
Jan 2, 2010, 7:51:40 PM1/2/10
to
Jean-Michel <jmc....@orange.fr> wrote:

> How did you do it, you predict the Iyonix date BUG ?

Tardis, probably.

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to newsre...@wingsandbeaks.org.uk replacing "nnn" by "284".

0 new messages