Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5798

Re: Dates as numbers in BASIC

Subject Re: Dates as numbers in BASIC
Newsgroups comp.sys.acorn.programmer
From Alan Adams <alan@adamshome.org.uk>
Date 2019-06-27 13:32 +0100
Message-ID <5111b1ca57.Alan.Adams@ArmX6.adamshome.org.uk> (permalink)
References <bbb9c2c957.Kevin@talktalk.net> <0cb5c9c957.harriet@blueyonder.co.uk> <57ca5d74e5a.m.conroy@owlart.co.uk> <57ca61b0cda.m.conroy@owlart.co.uk> <8759a9ca57.Alan.Adams@ArmX6.adamshome.org.uk>
Organization Orpheus Internet Services

Show all headers | View raw


In message <8759a9ca57.Alan.Adams@ArmX6.adamshome.org.uk>
          Alan Adams <alan@adamshome.org.uk> wrote:

> In message <57ca61b0cda.m.conroy@owlart.co.uk>
>           Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:

>> In article <57ca5d74e5a.m.conroy@owlart.co.uk>,
>>    Andrew Conroy <a.m.conroy@owlart.co.uk> wrote:
>>> In article <0cb5c9c957.harriet@blueyonder.co.uk>,
>>>    Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
>>>> On 25 Jun 2019 as I do recall,
>>>>           Kevin Wells  wrote:

>>>>> Hi
>>>>>
>>>>> How can you get the month as a number instead of the 3 letter
>>>>> shorterned name e.g?
>>>>>
>>>>> 06 instread of Jun

>>>>  Use OS_Word 14 to read the computer's clock as a 5-byte time value,
>>>>  then pass the resulting area of memory to OS_ConvertDateAndTime.

>>>> The format string for a three-letter shortened month name is %M3 and
>>>> for the month in numbers is %MN - see manuals.

>>> Or OS_ConvertDateAndTime or, better still,
>>> Territory_ConvertTimeToOrdinals to convert any 5 byte time block rather
>>> than just the current time. You'll then have to parse the result to get
>>> just the month.


>> There's also Territory_TimeStringToOrdinals which might be easier. Feed
>> in a dummy time string with the desired month in it, and back comes the
>> month number at offset &14 in the buffer.

>> Andrew

> For example:

> DIM wlib_block% 256

> DEF FNclocktime
> =FNclocktime2("%24:%MI:%SE")

> DEF FNclocktime2(format$)
> LOCAL rsize%,localtime%,result%
> IF LEN(format$) > 127 THEN format$=LEFT$(format$,127)
> localtime%=wlib_block%
> result%=wlib_block%+60
> rsize%=128
> ?localtime%=3
> SYS "OS_Word",14,localtime%
> SYS "Territory_ConvertDateAndTime",-1,localtime%,result%,rsize%,format$ TO
> ,rsize%
> REM SYS "OS_ConvertDateAndTime",localtime%,result%,rsize%,format$ TO
> ,rsize%
> ?rsize%=13
> =$result%

> For your case:

> FNclocktime2("%M3")

> will return the current 3-letter month.

while FNclocktime2("%MN") will return the month number, with 01 
representing January.


-- 
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Dates as numbers in BASIC Kevin Wells <kev@kevsoft.co.uk> - 2019-06-25 18:09 +0100
  Re: Dates as numbers in BASIC "John Williams (News)" <UCEbin@tiscali.co.uk> - 2019-06-25 18:45 +0100
  Re: Dates as numbers in BASIC Paul Oates <oatespaul@btinternet.com> - 2019-06-25 19:00 +0100
    Re: Dates as numbers in BASIC news@sprow.co.uk - 2019-06-27 05:47 -0700
      Re: Dates as numbers in BASIC Kevin Wells <kev@kevsoft.co.uk> - 2019-06-29 12:23 +0100
      Re: Dates as numbers in BASIC jgh@mdfs.net - 2019-07-03 11:47 -0700
  Re: Dates as numbers in BASIC Harriet Bazley <harriet@bazleyfamily.co.uk> - 2019-06-25 19:25 +0100
    Re: Dates as numbers in BASIC Andrew Conroy <a.m.conroy@owlart.co.uk> - 2019-06-26 22:19 +0100
      Re: Dates as numbers in BASIC Andrew Conroy <a.m.conroy@owlart.co.uk> - 2019-06-26 23:05 +0100
        Re: Dates as numbers in BASIC Alan Adams <alan@adamshome.org.uk> - 2019-06-27 12:08 +0100
          Re: Dates as numbers in BASIC Alan Adams <alan@adamshome.org.uk> - 2019-06-27 13:32 +0100

csiph-web