Re: [ql-users] month number
Dilwyn Jones wrote: > OK, I goofed on that one. > > I assumed (wrongly) that because JM allowed 6 parameters > on a JM ROM and appeared to return a vaguely right number I assumed it > worked. Except it just "pretends" to work and of course you can't tell > accurately from an E number where in the year it was until you do > detailed checks with storing DATE result then using DATE$ to see what > it makes of it - no parameter checks on JM it would seem. Using DATE > with 6 parameters on a JM ROM returns the same result as DATE with no > parameters. Or with any number of parameters! At least JS is kind > enough to give err_bp when you try :-( > > So I have been taught a lesson, not to let APPARENT results fool me. There were a few things that didn't work [properly] on the JM that when the JS came around, to avoid the problems, it just didn't allow them. eg upto JM, I seem to remember some sort of variable was allowed somewhere (was it integers on SELect? have the info lurking here somewhere), but I think something wasn't quite right, so JS just won't accept it in the first place I fell foul of something in a program I wrote for my JM that worked, but when I gave it to a friend to try on his JS, it didn't work - the JS just didn't accept one of the lines. At a guess either the DATE(yr,...) was intended to be, but it was never written, and so the JS errors; or it was a parameter check that was missing upto JM that was finally fixed in JS. ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Phew the SBASIC/SuperBASIC Reference Manual was right then !! On Tue, 26 Sep 2006 13:08:41 +0100, Dilwyn Jones <[EMAIL PROTECTED]> wrote: > OK, I goofed on that one. > > I assumed (wrongly) that because JM allowed 6 parameters > on a JM ROM and appeared to return a vaguely right number I assumed it > worked. Except it just "pretends" to work and of course you can't tell > accurately from an E number where in the year it was until you do > detailed checks with storing DATE result then using DATE$ to see what > it makes of it - no parameter checks on JM it would seem. Using DATE > with 6 parameters on a JM ROM returns the same result as DATE with no > parameters. Or with any number of parameters! At least JS is kind > enough to give err_bp when you try :-( > > So I have been taught a lesson, not to let APPARENT results fool me. -- Rich Mellor RWAP Services URL:http://www.rwapsoftware.co.uk URL:http://www.rwapadventures.com URL:http://www.rwapservices.co.uk URL:http://www.internetbusinessangels.com ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Marcel Kilgus writes: >> A good addition to that might be an ISO 8601 compatible WEEKNO% (week >> number). > > I only added the functions that are readily available (i.e. DATE$ had > to calculate all this anyway, it's just a matter of exposing the > values to BASIC). Was a 5 minutes job. I am aware of this; it was on my todo list. And that included SECONDS (below) too. >> I also often find SECONDS(year, month, day, hour, minutes, seconds) >> handy. > > What's the difference between SECONDS and DATE? Ahh, Id forgotten about this ;o) I see now that it is implemented in Smsq/e, not only in Minerva. AH..JM just return the current date though, while JS returns a Bad Parameter error. >> It might also be useful to have MONTH$(1..12 or DATE) and FDAY$(1..7 >> or DATE) (full day name) in the various languages. > > Where would one get the full day/month name from? Add it to the language module? Although my mail was somewhat tounge-in-cheek the points Im making are 1) This sort of thing could, to my mind, usefully be included in an OS under the philosophy that the OS provides a selection of basic building blocks for programs, and 2) Wherever possible to maintain compatability between OS variants for self-evident reasons. Obviously, I dont expect you to do all the work ;o) >> Finally, this should also be available as an add-on toolkit for Qdos >> users! Hmm, was there anything else I wonder? > > Well then, get working! :-) I already did, but my packaging is different, so Id have to make some changes. I also developed a calendar toolkit based on days, giving a much wider range of dates that could be calculated, but I see now that it is broken. However, my efforts were feeble compared to what appears to be an extremely competent calendar functionality already built in to Smsq/e by Jonathan Oakly! At a cursory glance it looks like it can potentially handle any date in any country (taking into account that different countries made the changeover from the Julian to the Gregorian calendar at different times, etc). The only things that appear to be missing are the bits to access it fully from Basic - and any documentation (though the code is well documented and beautifully written). Take a look at dev8_Smsq_util_cv_cvday_asm in the Smsq/e sources! Per ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
OK, I goofed on that one. I assumed (wrongly) that because JM allowed 6 parameters on a JM ROM and appeared to return a vaguely right number I assumed it worked. Except it just "pretends" to work and of course you can't tell accurately from an E number where in the year it was until you do detailed checks with storing DATE result then using DATE$ to see what it makes of it - no parameter checks on JM it would seem. Using DATE with 6 parameters on a JM ROM returns the same result as DATE with no parameters. Or with any number of parameters! At least JS is kind enough to give err_bp when you try :-( So I have been taught a lesson, not to let APPARENT results fool me. -- Dilwyn Jones - Original Message - From: "Rich Mellor" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, September 25, 2006 8:39 PM Subject: Re: [ql-users] month number > On Mon, 25 Sep 2006 20:40:17 +0100, Robert Newson > <[EMAIL PROTECTED]> wrote: > >> Dilwyn Jones wrote: >> >>>> Robert Newson wrote: >>>> >>>>> DATE returns the number of seconds [since 01/01/61] for the >>>>> /current/ >>>>> date/time (I suspect it just reads a/the clock); >>>>> >>>> It can read the clock, but you can also do >>>> PRINT DATE(1996,1,10,12,59,59) >>>> >>>> Marcel >>>> >>> I suspect most people don't know about this form of DATE, since >>> the QL >>> manual (Concepts - Date) does not list the 6 parameter version, >>> and >>> neither does the Jan Jones Superbasic guide. >> >> I certainly didn't. >> > > Odd - it was certainly pushed by Lau as one of the improvements made > by > Minerva - are you sure it works on a JM ROM or earlier?? > > > -- > Rich Mellor > RWAP Services > URL:http://www.rwapsoftware.co.uk > URL:http://www.rwapadventures.com > URL:http://www.rwapservices.co.uk > URL:http://www.internetbusinessangels.com > > ___ > QL-Users Mailing List > http://www.q-v-d.demon.co.uk/smsqe.htm > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: > 22/09/2006 > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 22/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Robert Newson wrote: > Just tried: > > PRINT DATE(1996,1,10,12,59,59) > > on my JS [ROMed QL - later than JM] and it comes up with: > > bad parameter > > /was/ it a Minerva improvement? So it would appear. From Minerva Technical Guide, section BAS.1: "The date procedures now accept a wider range of parameters. DATE accepts the six-parameter format formerly used by SDATE, allowing you to convert this form for use with DATE$ and DAY$ and SDATE now accepts a single parameter in additional to the original six parameter syntax. So: PRINT DATE$ (DATE(1962,3,21,9,0,0)) will print 1962 Mar 21 09:00:00 and more usefully PRINT DAY$(DATE(1962,3,21,9,0,0)) will print Wed" -- Regards, Stephen ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Rich Mellor wrote: ... It can read the clock, but you can also do PRINT DATE(1996,1,10,12,59,59) ... >>>I suspect most people don't know about this form of DATE, since the QL >>>manual (Concepts - Date) does not list the 6 parameter version, and >>>neither does the Jan Jones Superbasic guide. ... > Odd - it was certainly pushed by Lau as one of the improvements made by > Minerva - are you sure it works on a JM ROM or earlier?? Just tried: PRINT DATE(1996,1,10,12,59,59) on my JS [ROMed QL - later than JM] and it comes up with: bad parameter /was/ it a Minerva improvement? ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
On Mon, 25 Sep 2006 20:40:17 +0100, Robert Newson <[EMAIL PROTECTED]> wrote: > Dilwyn Jones wrote: > >>> Robert Newson wrote: >>> DATE returns the number of seconds [since 01/01/61] for the /current/ date/time (I suspect it just reads a/the clock); >>> It can read the clock, but you can also do >>> PRINT DATE(1996,1,10,12,59,59) >>> >>> Marcel >>> >> I suspect most people don't know about this form of DATE, since the QL >> manual (Concepts - Date) does not list the 6 parameter version, and >> neither does the Jan Jones Superbasic guide. > > I certainly didn't. > Odd - it was certainly pushed by Lau as one of the improvements made by Minerva - are you sure it works on a JM ROM or earlier?? -- Rich Mellor RWAP Services URL:http://www.rwapsoftware.co.uk URL:http://www.rwapadventures.com URL:http://www.rwapservices.co.uk URL:http://www.internetbusinessangels.com ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: >>Robert Newson wrote: >> >>>DATE returns the number of seconds [since 01/01/61] for the >>>/current/ >>>date/time (I suspect it just reads a/the clock); >>> >>It can read the clock, but you can also do >> PRINT DATE(1996,1,10,12,59,59) >> >>Marcel >> > I suspect most people don't know about this form of DATE, since the QL > manual (Concepts - Date) does not list the 6 parameter version, and > neither does the Jan Jones Superbasic guide. I certainly didn't. ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
> Robert Newson wrote: >> DATE returns the number of seconds [since 01/01/61] for the >> /current/ >> date/time (I suspect it just reads a/the clock); > > It can read the clock, but you can also do >PRINT DATE(1996,1,10,12,59,59) > > Marcel I suspect most people don't know about this form of DATE, since the QL manual (Concepts - Date) does not list the 6 parameter version, and neither does the Jan Jones Superbasic guide. It does work, even on Sinclair ROMs, just tried it on a JM ROM, just to reassure people it's not an SBASIC-specific version. -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 22/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Robert Newson wrote: > DATE returns the number of seconds [since 01/01/61] for the /current/ > date/time (I suspect it just reads a/the clock); It can read the clock, but you can also do PRINT DATE(1996,1,10,12,59,59) Marcel ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Marcel Kilgus wrote: ... > I only added the functions that are readily available (i.e. DATE$ had > to calculate all this anyway, it's just a matter of exposing the > values to BASIC). Was a 5 minutes job. Precisely what I would have done. >>I also often find SECONDS(year, month, day, hour, minutes, seconds) >>handy. > > What's the difference between SECONDS and DATE? DATE returns the number of seconds [since 01/01/61] for the /current/ date/time (I suspect it just reads a/the clock); SECONDS takes 6 params (or possibly a single string param) and converts them (it) into the number of seconds [since 01/01/61] ie SECONDS allows a programmer to convert any arbitrary date[-time] into internal format - the inverse of the DATE$(). ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
P Witte wrote: > A good addition to that might be an ISO 8601 compatible WEEKNO% (week > number). I only added the functions that are readily available (i.e. DATE$ had to calculate all this anyway, it's just a matter of exposing the values to BASIC). Was a 5 minutes job. > I also often find SECONDS(year, month, day, hour, minutes, seconds) > handy. What's the difference between SECONDS and DATE? > It might also be useful to have MONTH$(1..12 or DATE) and FDAY$(1..7 > or DATE) (full day name) in the various languages. Where would one get the full day/month name from? > Finally, this should also be available as an add-on toolkit for Qdos > users! Hmm, was there anything else I wonder? Well then, get working! :-) Marcel ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: > (1) values returned are integers (assume so since function names end > in %) Yes. > (2) your count system starts at 1 or 0 for month and day in month 1 > (3) and for weekdays, I assume Sunday is day 1? And they work as 1 to > 7, or 0 to 6? Sun = 0, Mon = 1 etc. > LET y% = YEAR% : REMark 4 digit year number > LET m% = MONTH% : REMark number from 1 to 12 > LET d% = DAY% : REMark number from 1 to 31 > LET wd% = WEEKDAY% :REMark number from 1 to 7, Sunday to Saturday? Last one is 0 to 6, but apart from that it's correct. Marcel ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
> Dilwyn Jones wrote: >> Oops, I feel an article rewrite coming on... Jochen and Geoff, >> don't >> use it yet until I've had time to digest this!!! (I'm on SMSQ/E >> 3.12, >> so didn't know about this.) > > As even I forgot about it, nobody knew! 3.13 is still not released > yet. But the commands will be part of the next release, which is > hopefully around the corner. I can send you an SMSQ/E with the > commands if you want. But basically they behave the same as DATE, > just > that they return the month, year etc instead. > > Marcel No need to send anything (thank you), I'll wait for the general releases. Can I just check if this is how they work (for mention in the article) All I'm concerned about is whether (1) values returned are integers (assume so since function names end in %) (2) your count system starts at 1 or 0 for month and day in month (3) and for weekdays, I assume Sunday is day 1? And they work as 1 to 7, or 0 to 6? LET y% = YEAR% : REMark 4 digit year number LET m% = MONTH% : REMark number from 1 to 12 LET d% = DAY% : REMark number from 1 to 31 LET wd% = WEEKDAY% :REMark number from 1 to 7, Sunday to Saturday? -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 22/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Marcel Kilgus writes: > On the subject of month numbers, I totally forgot about this, but I > did actually implement the functions YEAR%, MONTH%, DAY% and WEEKDAY% > for SMSQ/E 3.13 a few months ago. > Just noticed now while doing release sync with Wolfgang. A good addition to that might be an ISO 8601 compatible WEEKNO% (week number). I also often find SECONDS(year, month, day, hour, minutes, seconds) handy. It might also be useful to have MONTH$(1..12 or DATE) and FDAY$(1..7 or DATE) (full day name) in the various languages. Finally, this should also be available as an add-on toolkit for Qdos users! Hmm, was there anything else I wonder? Per ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: > Oops, I feel an article rewrite coming on... Jochen and Geoff, don't > use it yet until I've had time to digest this!!! (I'm on SMSQ/E 3.12, > so didn't know about this.) As even I forgot about it, nobody knew! 3.13 is still not released yet. But the commands will be part of the next release, which is hopefully around the corner. I can send you an SMSQ/E with the commands if you want. But basically they behave the same as DATE, just that they return the month, year etc instead. Marcel ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Oops, I feel an article rewrite coming on... Jochen and Geoff, don't use it yet until I've had time to digest this!!! (I'm on SMSQ/E 3.12, so didn't know about this.) -- Dilwyn Jones - Original Message - From: "Marcel Kilgus" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, September 23, 2006 12:10 PM Subject: Re: [ql-users] month number > On the subject of month numbers, I totally forgot about this, but I > did actually implement the functions YEAR%, MONTH%, DAY% and > WEEKDAY% > for SMSQ/E 3.13 a few months ago. > Just noticed now while doing release sync with Wolfgang. > > Marcel > > ___ > QL-Users Mailing List > http://www.q-v-d.demon.co.uk/smsqe.htm > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: > 22/09/2006 > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.8/455 - Release Date: 22/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
On the subject of month numbers, I totally forgot about this, but I did actually implement the functions YEAR%, MONTH%, DAY% and WEEKDAY% for SMSQ/E 3.13 a few months ago. Just noticed now while doing release sync with Wolfgang. Marcel ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
In message <[EMAIL PROTECTED]>, Dilwyn Jones <[EMAIL PROTECTED]> writes >>>Aaargh, sorry this was meant to go direct to Robert! >>> >>>That's me blacklisted now I guess. >>> >>>Robert, I'll send it separately again, as the attachment may not >>>have >>>made it through to the list. >>> >>>-- >>>Dilwyn Jones >> >> There was no attachment ... so saved by the error . :-) >> >> -- >> Malcolm Cadman >In fact, looking at my Sent directory, I did send an attachment, so >either the list filters them out or the fact that I send as Plain Text >causes it to be lost before it gets to the list. Phew. >-- >Dilwyn Jones Umm ... I don't know about that. However, embarrassment saved. -- Malcolm Cadman ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
>>Aaargh, sorry this was meant to go direct to Robert! >> >>That's me blacklisted now I guess. >> >>Robert, I'll send it separately again, as the attachment may not >>have >>made it through to the list. >> >>-- >>Dilwyn Jones > > There was no attachment ... so saved by the error . :-) > > -- > Malcolm Cadman In fact, looking at my Sent directory, I did send an attachment, so either the list filters them out or the fact that I send as Plain Text causes it to be lost before it gets to the list. Phew. -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
In message <[EMAIL PROTECTED]>, Dilwyn Jones <[EMAIL PROTECTED]> writes > >Aaargh, sorry this was meant to go direct to Robert! > >That's me blacklisted now I guess. > >Robert, I'll send it separately again, as the attachment may not have >made it through to the list. > >-- >Dilwyn Jones There was no attachment ... so saved by the error . :-) -- Malcolm Cadman ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Aaargh, sorry this was meant to go direct to Robert! That's me blacklisted now I guess. Robert, I'll send it separately again, as the attachment may not have made it through to the list. -- Dilwyn Jones - Original Message - From: "Dilwyn Jones" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 21, 2006 6:01 PM Subject: Re: [ql-users] month number >>> In fact, as I was given permission to include those articles on >>> the >>> Documentation CD, may I ask you if I can also include these >>> routines >>> as >>> well? >> >> Sure. > Thanks for letting me use the routines, Robert. > > > month_doc attached was written in Xchange, so MIGHT not load into > standard Quill (not tried it). > > -- > Dilwyn Jones > > ___ > QL-Users Mailing List > http://www.q-v-d.demon.co.uk/smsqe.htm No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
In fact, as I was given permission to include those articles on the Documentation CD, may I ask you if I can also include these routines as well? Sure. Thanks for letting me use the routines, Robert. With coincidental timing, I was asked to come up with an article for QL Toady and Quanta (as the last one I wrote went to Quanta, this one is Toady's turn), so I wrote the whole thing up as a Quill doc file to send them as well as to put on the Documentation CD, but I thought that as I don't fully understand your routines, I'd quote in the article from your emails and credit you accordingly, but thought I'd better send you a copy first in case you wish to change anything befroe I send it to the supreme Toady (Jochen or Geoff!) month_doc attached was written in Xchange, so MIGHT not load into standard Quill (not tried it). -- Dilwyn Jones No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Thank you, consider it added! -- Dilwyn Jones - Original Message - From: "Robert Newson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 20, 2006 8:33 PM Subject: Re: [ql-users] month number > Dilwyn Jones wrote: > > ... >> In fact, as I was given permission to include those articles on the >> Documentation CD, may I ask you if I can also include these >> routines >> as >> well? > > Sure. > I'm not a very good technical author (and I'm currently half > asleep), so > I'll write what it does and I'll let you tidy it up (if you want > to). > > 8<8<8<8<8<8<8<8< > > > The way it works is by using a calendar based on day 0 = 1 March > 1960. The > "year" in this calendar runs from 1 March to 28/29 February - the > leap day OK, many thanks. -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
>>> PS Still puzzled re; diff between O.S. and 'platform' in our >>> recent >>> context. >>> :( >> The operating system (QDOS or Windows) is that which is running >> your >> programs and making sure all the hardware bits and pieces of your >> computer work properly (or not as the case may be). >> >> The 'platform' in this context means the computer hardware on which >> the operating system being used is based. Thus if you are running >> QPC2 > <> > > I dont see it like that. For me the platform is the QL hardware or > QL > emulator the QL OS is running on. Ie QL, Q60, QPC2, uQLx are all > platforms. > In the case of emulators, that platform would again be be running on > a host > platform, such as a PC, under a host OS such as Linux or Windows. > > Per You are so right, this is partly why I was a little cautious with the explanation, with the ifs and buts. Emulators do obscure the issue somewhat! If you are speaking 'QL' without being interested in the underlying machine then yes the platform would be QPC2, Q40 or whatever. The only clear way is to imply it in a reply I suppose... "platform was a PC running Linux on which I was running uQLx" or whatever. I suppose in the original context you are totally right - the 'platform' is indeed the QL "system" on which it's running. Especially if we aren't interested in the underlying operating system or hardware. Most QL emulators immerse you in QDOS or SMSQ/E without you having to know much about what's underneath, and if you are running a native system (QL, Aurora or Qx0) it doesn't matter anyway. So, Hitchies, assume Per's reply is a shorter (and clearer) explanation than mine. -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.6/453 - Release Date: 20/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones writes: <> >> PS Still puzzled re; diff between O.S. and 'platform' in our recent >> context. >> :( > The operating system (QDOS or Windows) is that which is running your > programs and making sure all the hardware bits and pieces of your > computer work properly (or not as the case may be). > > The 'platform' in this context means the computer hardware on which > the operating system being used is based. Thus if you are running QPC2 <> I dont see it like that. For me the platform is the QL hardware or QL emulator the QL OS is running on. Ie QL, Q60, QPC2, uQLx are all platforms. In the case of emulators, that platform would again be be running on a host platform, such as a PC, under a host OS such as Linux or Windows. Per ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: ... > In fact, as I was given permission to include those articles on the > Documentation CD, may I ask you if I can also include these routines > as > well? Sure. > If so, a few lines explaining the algorithm may be in order. I > understand parts of it, but not all of it: for example what's the > significance of the (dy+0.8) ? It's the "Fudge factor" to get the leap year calculations correct - it could possibly be removed by changing the base year (of the shifted year) from 1960 to 1959 (and adding an extra 366, ie +972 instead of +306 to the days) but I haven't checked it: 0.8 was chosen, as otherwise the first year would be a leap year with 366 days (0-365), the 2nd would then be days 366-730, 3rd 731-1095, 4th 1096-1460; the 5th would also be a leap year. The my_mth_no() fn is just the month stuff extracted from my_date proc, so I'll just explain my_date. I'm not a very good technical author (and I'm currently half asleep), so I'll write what it does and I'll let you tidy it up (if you want to). 8<8<8<8<8<8<8<8< The way it works is by using a calendar based on day 0 = 1 March 1960. The "year" in this calendar runs from 1 March to 28/29 February - the leap day is added at the end of the year, every 1460 days. (4 years) Having the leap day at the end of the year means that we don't have to worry about it when working out the day offset for any date in the year 1 March or later. As we're passed seconds, we divide by 86400 = 24 * 60 * 60, the number of seconds in a day and ignore the fraction. The passed date needs to be adjusted for our shifted year and as day 306 is 1 January 1961, an offset of 306 is added. The current year is calculated from the base by checking out every 365.25 days. (The "fudge factor" of (dy + 0.8) simplifies the calculation so that yr 0 = days 0-364, yr 1 = 365-729, yr 2 = 730-1094, yr 3 (leap) = 1095-1460, etc.) Once the relative year to the base year is found, the number of days until the start of that year is removed leaving the day offset within the year. The number 30.6 is useful in that its multiples, when ignoring the fraction bit, provide an increase of 30, 31, 30, 31, 31 which then repeats. This matches the number of days in each of the months in the year that need to be added to get to the start of the current month: 31 (March), 30 (April), 31, 30, 31, 31, 30, 31, 30, 31, 31 (February has 28/29 which then starts the next year and so we don't need it). Adding 31 to the current day number corrects for the sequence of the multiples of 30.6 so that it matches the month sequence. Dividing by 30.6 then gives the month number in the shifted year. We need to subtract the number of days in the month(s) preceeding this one from the day offset in the year. Again, we need to shift the 30.6 sequence and the (mn + 3) provides this. However, we also have to correct for INT(30.6 * 3) = 92 extra days which are subtracted, so we need to add them back with a +92 Finally the shifted month is corrected for the real year by adding 2. If the resultant month is > 12 (ie a month past December, ie January or February), subtract 12 from the month number and add one to the year. The year is corrected to the real year by adding the base year of 1960. ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
"Google is your friend"--e.g. googling "zeller's congruence" for starters or just visiting US NIST or similar will turn things up. I've been thinking to mention zeller's for some time. Maybe that's one thing the QLT articles dealt with; I haven't looked in a while to say the least. Doug L. 37830 USA -Original Message- >From: Dilwyn Jones <[EMAIL PROTECTED]> >Sent: Sep 20, 2006 1:22 PM >To: QL Users List <[EMAIL PROTECTED]> >Subject: Re: [ql-users] month number > >>>>Is there a way of returning the current month as a number? >>> >>> I had thought I had come up with a function for this, but it is >>> getting the >>> ends of some months wrong, eg 1 May is coming out as 31 Apr! (Which <...snip...> ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
>>>Is there a way of returning the current month as a number? >> >> I had thought I had come up with a function for this, but it is >> getting the >> ends of some months wrong, eg 1 May is coming out as 31 Apr! (Which >> seems >> odd as I thought I had checked out all the month bounds when >> writing the >> function...I'll have another look at it tomorrow.) > > Had a fiddle with it this evening, and seem to have solved the > problems > (I've checked it against the QL's DATE$() and it's matched as far as > today > from 1 Jan 1961): > I could have set a string and made it a function, but the whole > point of the > exercise was that you were trying to extract the day/month/year from > the > DATE$ (if I understood you properly) and it would have been a bit > silly to > package them up in a string to be unpackaged again afterwards. An > alternative would be to add the three elements together, eg: > > packed = (year - 1961) * 372 + (month - 1) * 31 + day - 1 > > Then: > > day = packed MOD 31 + 1 > month = INT(packed / 31) MOD 12 + 1 > year = 1961 + INT(packed / 372) > > my_mth_no takes one param: secs since ~ and returns the month number > of that > date: > > month = my_mth_no(secs) > > > Any help? Yes! Thank you. I can see this is very useful if th emethod I'm actually using fails to work for any reason. It's a very different approach to that which I took, which is more like that suggested by Wolfgang - extracting the 'active' language data by using DATE$ with a parameter at various steps in the clock's first year to extract the month names, and date$ with day-length steps to extract the day names. I have a DATA list of the full month names for the calendar display in the languages currently supported by SMSQ/E, and if the LANGUAGE function returns a value unknown to QDiary, it simply defaults to using the 3 letter month names extracted as Wolfgang suggested. It seems to work even if the programming is a little clumsy and not as tidy as I'd like. There were articles in QL Today about calendars and time-related subjects (especially liked the Star Trek stardates!) which have also been very helpful. In fact, as I was given permission to include those articles on the Documentation CD, may I ask you if I can also include these routines as well? If so, a few lines explaining the algorithm may be in order. I understand parts of it, but not all of it: for example what's the significance of the (dy+0.8) ? -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Robert Newson wrote: OOps, typo: Obviously this: DEF my_mth_no(secs) should be DEF FN my_mth_no(secs) > LOC dy, yr, mn > dy = INT(secs / 86400) + 306 > yr = INT((dy + .8) / 365.25) > mn = INT((dy - INT(yr * 365.25) + 31) / 30.6) + 2 > IF mn > 12 : mn = mn - 12 > RET mn > END DEF ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Robert Newson wrote: > Dilwyn Jones wrote: > >>A help request: >> >>Is there a way of returning the current month as a number? > > I had thought I had come up with a function for this, but it is getting the > ends of some months wrong, eg 1 May is coming out as 31 Apr! (Which seems > odd as I thought I had checked out all the month bounds when writing the > function...I'll have another look at it tomorrow.) Had a fiddle with it this evening, and seem to have solved the problems (I've checked it against the QL's DATE$() and it's matched as far as today from 1 Jan 1961): DEF PROC my_date(secs, dy, mn, yr) dy = INT(secs / 86400) + 306 yr = INT((dy + .8) / 365.25) dy = dy - INT(yr * 365.25) + 31 mn = INT(dy / 30.6) dy = dy - INT((mn + 3) * 30.6) + 92 mn = mn + 2 IF mn > 12 : mn = mn - 12 : yr = yr + 1 yr = yr + 1960 END DEF DEF my_mth_no(secs) LOC dy, yr, mn dy = INT(secs / 86400) + 306 yr = INT((dy + .8) / 365.25) mn = INT((dy - INT(yr * 365.25) + 31) / 30.6) + 2 IF mn > 12 : mn = mn - 12 RET mn END DEF If you want an explaination of how they [supposedly] work, I'll be more than happy to [try and] explain the algorithm. my_date has been made a PROCedure which modifies its calling parameters as more than 1 variable has to be set: my_date secs, day, month, year secs = number of secs since 01.01.1961 00:00:00 of date to extract day = stored with day of month (1-31) month = stored with month number (1-12) year = stored with year (1961-2099)[1] [1] Not checked beyond today. 2100 would be wrong (after 28.02.2100) as the proc/fn doesn't realise it will not be a leap year; however, for the required app, I don't think that would be too much of a problem. I could have set a string and made it a function, but the whole point of the exercise was that you were trying to extract the day/month/year from the DATE$ (if I understood you properly) and it would have been a bit silly to package them up in a string to be unpackaged again afterwards. An alternative would be to add the three elements together, eg: packed = (year - 1961) * 372 + (month - 1) * 31 + day - 1 Then: day = packed MOD 31 + 1 month = INT(packed / 31) MOD 12 + 1 year = 1961 + INT(packed / 372) my_mth_no takes one param: secs since ~ and returns the month number of that date: month = my_mth_no(secs) Any help? ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
> Dilwyn (with one 'n') said - Oh dear, I'm not going to hear the last of that now am I? > "...The collective sharing of information and ideas is a brilliant > feature > of the QL > scene. " > > Couldn't agree more! > > Have a good one, wherever you are. > > John in Wales > > PS Still puzzled re; diff between O.S. and 'platform' in our recent > context. > :( The operating system (QDOS or Windows) is that which is running your programs and making sure all the hardware bits and pieces of your computer work properly (or not as the case may be). The 'platform' in this context means the computer hardware on which the operating system being used is based. Thus if you are running QPC2 on Windows, the platform would probably be a PC, the operating system Windows running emulated SMSQ/E. If you are running uQLx on a Linux operating system, the platform could be a PC or vaguely referred to as a 'Linux box'. It can become a little confusing in some cases - if you try to run a QL emulator on some other emulated system (e.g. a Linux system running a Windows emulation on which you run a copy of QLay emulator). If you are running QDOS on a QL, the platform is a QL. If you are running QDOS Classic on a Q60, the platform is the Q60. It is not clear cut though, some people take 'platform' to mean the system on which your 'QL' is running, so platform in that case might refer to the PC or to the host operating system. Emulators do tend to blur definitions a little! As a quick rough and ready explanation, take the word 'platform' to mean the system on which your 'QL' is running, but you might have to take a guess as to whether the writer is referring to the hardware (computer system) or the software controlling it (the operating system) from the context of what was being discussed. Hope that helps a little! -- Dilwynnn Jonnes -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn (with one 'n') said - "...The collective sharing of information and ideas is a brilliant feature of the QL scene. " Couldn't agree more! Have a good one, wherever you are. John in Wales PS Still puzzled re; diff between O.S. and 'platform' in our recent context. :( -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/449 - Release Date: 15/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: > A help request: > > Is there a way of returning the current month as a number? I had thought I had come up with a function for this, but it is getting the ends of some months wrong, eg 1 May is coming out as 31 Apr! (Which seems odd as I thought I had checked out all the month bounds when writing the function...I'll have another look at it tomorrow.) ... > Seems so clumsy I'm sure there must be a better way! I need to use it > in my diary program to find entries for the current day or current > month. The only other idea I've come up with so far is to take the > value of DATE as seconds from DATE=0 and try to divide by the number > of seconds per year and per month, taking into account leap years! Not quite, it's just a matter of correcting for a different base: taking date(0)=01 Mar 1960 makes taking leap years into account dead easy[1]. It's just a matter of then working out the current month within the shifted year (also slightly easier as the days pattern is regular for the first 11 months) and correcting for the Gregorian year. [1] By using a year starting on 1 Mar, leap days are added after the last day (Feb 28 of the next Gregorian year) in the year; and don't forget that 1960 was a leap year so the previous year in this system was a leap year and the next one will be in 4 years time! ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Thanks. I had tried a similar piece of code myself, based on the fact that DATE=0 gives 1st January 1961, which (usefully) is a sunday. Stepping along that first year in units of the number of seconds in a 31 day month (doesn't matter where in the month thatmonth*31days happens to fall) allows DATE$(month*seconds_per_month) to return a string for somewhere in that month which allows you to extract the 3 digit month abbreviation and build up a template string of all the month names. I can also do the same for day names, again by using the fact that 1/1/1961 is a sunday. So work out the number of seconds per day and and use DAY$(day*seconds_per_day) to extract the day name: days$='' seconds_per_day = 24*60*60 FOR a=0 to 6:days$=days$&DAY$(a*seconds_per_day) A fairly easy way to extract the language-dependent information for calendar headings, which is reliable as long as DATE=0 always remains at 1/1/1961 Rather late in the day I realised I'd have to make my diary program work for the other language modules allowed by SMSQ/E and wanted to try to find a way which would work with the currently supported modules (English, French, German, Italian and Spanish - LANGUAGE=34 is allowed but there seems to be no module for Spanish). Working as people have suggested using routines like the above allows future languages to be used too, as long as DATE=0 always signifies 1/1/1961 as it does on current machines. I also liked Francois's method of using a temporary language, although it wouldn't work in the specific context of my program. Once again this list has proved its worth to me! The collective sharing of information and ideas is a brilliant feature of the QL scene. -- Dilwyn Jones - Original Message - From: "Wolfgang Lenerz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, September 19, 2006 6:43 AM Subject: Re: [ql-users] month number > On 18 Sep 2006 at 17:17, Dilwyn Jones wrote: > >> A help request: > > > Hope this helps : > > > DEFine FuNction make_all_months$ > rem this makes a string "JanFeb..." in the current language > rem this should be called during the initialisation part > rem eg. all_months$=make_all_months$ > LOCal string$,lp%,a$,temp > string$="":a$="":temp=0 > temp=60*60*24*31 > FOR lp%=0 TO 11 >a$=DATE$(lp%*temp) >string$=string$&a$(6 TO 8) > END FOR lp% > RETurn string$ > END DEFine make_all_months$ > : > DEFine FuNction make_date$(dflag%,what_date) > rem returns date as "01.01.1991" (dflag%=1) or "1991.01.31" > (dflag%=0) > rem if what_date<>0, then it is this date that will be returned > rem this presumes that a variable "all_month$" exists! > LOCal a$,b$,res > b$="" > IF what_date >a$=DATE$(what_date) : rem make date passed as param into > string > ELSE >a$=DATE$: rem current date into string > END IF > b$=a$(6 TO 8) : rem 3 letter month abbreviation > res= b$ INSTR all_months$ : rem find it > IF NOT res > all_months$=make_all_months$ : rem not found?, make > all_month$ > res= b$ INSTR all_months$: rem and retry > END IF > res=(res+2)/3 : rem this is the month in figures > b$=res:IF res<10:b$="0"&b$: rem add leading 0 if > necessary > IF dflag%:RETurn a$(10 TO 11)&"."&b$&"."&a$(1 TO 4) > RETurn a$(1 TO 4)&"."&b$&"."&a$(10 TO 11) > END DEFine make_date$ > : > Should be self eplanatory. > > Wolfgang > -- > W. H. Lenerz > www.scp-paulet-lenerz.com > -- > ___ > QL-Users Mailing List > http://www.q-v-d.demon.co.uk/smsqe.htm > > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: > 14/09/2006 > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
On 18 Sep 2006 at 17:17, Dilwyn Jones wrote: > A help request: Hope this helps : DEFine FuNction make_all_months$ rem this makes a string "JanFeb..." in the current language rem this should be called during the initialisation part rem eg. all_months$=make_all_months$ LOCal string$,lp%,a$,temp string$="":a$="":temp=0 temp=60*60*24*31 FOR lp%=0 TO 11 a$=DATE$(lp%*temp) string$=string$&a$(6 TO 8) END FOR lp% RETurn string$ END DEFine make_all_months$ : DEFine FuNction make_date$(dflag%,what_date) rem returns date as "01.01.1991" (dflag%=1) or "1991.01.31" (dflag%=0) rem if what_date<>0, then it is this date that will be returned rem this presumes that a variable "all_month$" exists! LOCal a$,b$,res b$="" IF what_date a$=DATE$(what_date) : rem make date passed as param into string ELSE a$=DATE$: rem current date into string END IF b$=a$(6 TO 8) : rem 3 letter month abbreviation res= b$ INSTR all_months$ : rem find it IF NOT res all_months$=make_all_months$ : rem not found?, make all_month$ res= b$ INSTR all_months$: rem and retry END IF res=(res+2)/3 : rem this is the month in figures b$=res:IF res<10:b$="0"&b$: rem add leading 0 if necessary IF dflag%:RETurn a$(10 TO 11)&"."&b$&"."&a$(1 TO 4) RETurn a$(1 TO 4)&"."&b$&"."&a$(10 TO 11) END DEFine make_date$ : Should be self eplanatory. Wolfgang -- W. H. Lenerz www.scp-paulet-lenerz.com -- ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones schreef: > A help request: > > Is there a way of returning the current month as a number? > > Using DATE$ obviously returns the month name, but that is language > dependent. It would be fairly easy to use a piece of code like: > > lang=LANGUAGE > dte$=DATE$ > month$=dte$(6 TO 8) > SEL ON lang > =1,44:month_no=month$ INSTR 'JanFebMarAprMayJunJulAugSepOctNovDec': > rem English > =33:month_no=month$ INSTR 'JanFévMarAvrMaiJunJulAoûSepOctNovDéc' : rem > French > =49:month_no=month$ INSTR 'JanFebMärAprMaiJunJulAugSepOktNovDez' : rem > German > =39:month_no=month$ INSTR 'GenFebMarAprMagGiuLugAgoSetOttNovDic' : rem > Italian > =34:month_no=month$ INSTR 'EneFebMarAbrPueJunJulAgoSepOctNovDic' : rem > Spanish > rem and so on for all languages supported > END SEL > month_no=(month_no-1) DIV 3 > > Seems so clumsy I'm sure there must be a better way! I need to use it > in my diary program to find entries for the current day or current > month. The only other idea I've come up with so far is to take the > value of DATE as seconds from DATE=0 and try to divide by the number > of seconds per year and per month, taking into account leap years! > Almost as clumsy. I suppose the month number probably exists somewhere > in the OS to select which month name to take from the language > dependent modules. > > (Incidentally, easy way to crash QPC2 and sometimes take Windows with > it...SDATE 0,0,0,0,0,0, not that you'd want to!) > > So...help, please! > Hi Dilwyn, could the following function do the trick? > 125 DEFine FuNction month_number > 130 LOCal temp_months$,r > 135 LOCal temp_lang > 140 temp_lang=LANGUAGE > 145 IF temp_lang<>1:LANG_USE 1:END IF > 150 dte$=DATE$ > 155 temp_month$='JanFebMarAprMayJunJulAugSepOctNovDec': > 160 mt$=dte$(6 TO 8) > 165 r= mt$ INSTR temp_month$ :r=INT(r/3)+1 > 190 LANG_USE temp_lang > 195 RETurn r > 200 END DEFine month_number François Van Emelen ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
Re: [ql-users] month number
Dilwyn Jones wrote: > A help request: > > Is there a way of returning the current month as a number? ... > Seems so clumsy I'm sure there must be a better way! I need to use it > in my diary program to find entries for the current day or current > month. The only other idea I've come up with so far is to take the > value of DATE as seconds from DATE=0 and try to divide by the number > of seconds per year and per month, taking into account leap years! > Almost as clumsy. I suppose the month number probably exists somewhere > in the OS to select which month name to take from the language > dependent modules. It probably takes the date in seconds and converts that, taking into account leap years! Talking of which, when I wrote a date converter years ago (dd/mm/yy -> secs & secs -> dd/mm/yy), I found it easier to work with the year starting on March 1 - then the leap day is added at the "end of the year" - and correcting for that in the secs. I'll see if I can dig up the code for you (I later changed it to use localtime(), but I have my original somewhere - I may just re-write it). I also wrote a diary and a year planner printing programs. They handle festivals (Easter, GMT/BST, etc) which are printed, so I'm sure they use some sort of secs->date conversion - I know the planner uses a formula I found in PC World magazine years ago that [seems to] work for any year {summat like} 20,000 BC/AD (including 1752AD, but I'm not sure about the odd leap years that occured around the BC/AD time). > So...help, please! I'll see what I can dig up tomorrow (before I have to go out). ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
[ql-users] month number
A help request: Is there a way of returning the current month as a number? Using DATE$ obviously returns the month name, but that is language dependent. It would be fairly easy to use a piece of code like: lang=LANGUAGE dte$=DATE$ month$=dte$(6 TO 8) SEL ON lang =1,44:month_no=month$ INSTR 'JanFebMarAprMayJunJulAugSepOctNovDec': rem English =33:month_no=month$ INSTR 'JanFévMarAvrMaiJunJulAoûSepOctNovDéc' : rem French =49:month_no=month$ INSTR 'JanFebMärAprMaiJunJulAugSepOktNovDez' : rem German =39:month_no=month$ INSTR 'GenFebMarAprMagGiuLugAgoSetOttNovDic' : rem Italian =34:month_no=month$ INSTR 'EneFebMarAbrPueJunJulAgoSepOctNovDic' : rem Spanish rem and so on for all languages supported END SEL month_no=(month_no-1) DIV 3 Seems so clumsy I'm sure there must be a better way! I need to use it in my diary program to find entries for the current day or current month. The only other idea I've come up with so far is to take the value of DATE as seconds from DATE=0 and try to divide by the number of seconds per year and per month, taking into account leap years! Almost as clumsy. I suppose the month number probably exists somewhere in the OS to select which month name to take from the language dependent modules. (Incidentally, easy way to crash QPC2 and sometimes take Windows with it...SDATE 0,0,0,0,0,0, not that you'd want to!) So...help, please! -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006 ___ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm