Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.sinclair > #70 > unrolled thread
| Started by | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| First post | 2011-03-15 10:26 +0000 |
| Last post | 2011-03-23 21:32 +0000 |
| Articles | 13 — 5 participants |
Back to article view | Back to comp.sys.sinclair
Re: Conversion of ISO Date-stamps into Weekday Numbers lachman@ebony.ppc.ubc.ca (Milton Lachman) - 2011-03-15 10:26 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers lachman@ebony.ppc.ubc.ca (Milton Lachman) - 2011-03-15 12:00 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers "Brian Gaff" <Briang1@blueyonder.co.uk> - 2011-03-16 10:15 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers spike1@freenet.co.uk - 2011-03-16 12:26 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers "Brian Gaff" <Briang1@blueyonder.co.uk> - 2011-03-17 08:36 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers spike1@freenet.co.uk - 2011-03-17 09:36 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers korax1214 <korax1214@gmail.com> - 2011-03-17 16:15 -0700
Re: Conversion of ISO Date-stamps into Weekday Numbers jgharston <jgh@arcade.demon.co.uk> - 2011-03-17 17:49 -0700
Re: Conversion of ISO Date-stamps into Weekday Numbers "Brian Gaff" <Briang1@blueyonder.co.uk> - 2011-03-18 07:10 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers lachman@ebony.ppc.ubc.ca (Milton Lachman) - 2011-03-23 18:06 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers jgharston <jgh@arcade.demon.co.uk> - 2011-03-24 16:04 -0700
Re: Conversion of ISO Date-stamps into Weekday Numbers lachman@ebony.ppc.ubc.ca (Milton Lachman) - 2011-03-27 16:48 +0000
Re: Conversion of ISO Date-stamps into Weekday Numbers lachman@ebony.ppc.ubc.ca (Milton Lachman) - 2011-03-23 21:32 +0000
| From | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| Date | 2011-03-15 10:26 +0000 |
| Subject | Re: Conversion of ISO Date-stamps into Weekday Numbers |
| Message-ID | <ilnet7$svj$1@droog.sdf-eu.org> |
HOW TO COMPUTE THE DAY OF THE WEEK FOR DATE-STAMPS 10010101 TO 99991231
- using Hans Lachman's Method of Congruence as generalised below -
Strictly adhering to Lachman's Maxim (Complexity is a diseconomy of scale),
this method is designed to run superbly as a stand-alone subroutine, when
the most basic of computer is the only resource--meaning no values needed
from user tables or system calls, and no floating point variables.
Although using a processor more sophisticated than found on four-function
calculators, this method is simpler to execute than Hans' original Method
of Congruence needing manipulation of data by numerically competent users.
It succeeds where other Methods do not when computing the day of the week
even on lowly Sinclair ZX BASIC: having no need of extra instructions for
data stored in tables as in Babwani's Method nor for redundant operations
as in Zeller's or Tondering's--nor even a C compiler running on a bloated
development system as in Mike Keith's-- yet doing more in under 12 lines.
Given:
D$(8) as a Date-stamp YYYYMMDD in basic ISO format,
N% as its amount of shifting,
& F% as a false flag for non-Gregorian calendars:
300 0 Julian (historical)
301 0 Byzantine
325 0 Old-Style
300 50 Gregorian (historical);
K% as an addend (19300 for integer arithmetic)
X% as a multiplier (256 for integer arithmetic)
the Sinclair BASIC subroutine below is to compute:
y% as the Year
m% as the month
m$ whereby m$(2TO3)=MonthIndex
d% as the day's number within the month
i% as an increment to K%
w% as the ISO-compatible number of the corresponding weekday:
Sun=0 Mon=1 Tue=2 Wed=3 Thu=4 Fri=5 Sat=6
REM Step 0 - isolate components of & offset the Date-stamp:
LET y%=D$(1TO4) : m%=D$(5TO6) : d%=D$(7TO8) : s$=D$-N% : i%=F%+F%
IF N%=301 THEN
IF m%>8 THEN LET s$(1TO4)=s$(1TO4)-1
IF s$(5TO6)<6 THEN LET i%=100
END IF
IF N%=325 THEN
IF s$(5TO8)>9775 THEN LET i%=100
IF s$(5TO8)>9975 THEN LET s$(1TO4)=s$(1TO4)+1
END IF
REM Step 1 - compute the MonthIndex:
LET m$=m%*X% + K% + i%
REM Step 2 - compute the weekday-number:
LET w%=(s$(1TO4)DIV4 + y% + m$(2TO3) + d% + F%*s$(1TO2)DIV8 + F%)MOD7
The subroutine is streamlined such that parameters are to be passed in
proper format. For example, one must pass a flag of 50 for Gregorian
dates as of 15.oct.1582 A.D, & 0 for non-Gregorian as of 1.jan.1001:
A.D. for Julian & Old Style calendars; & A.M. for Byzantine calendars.
The subroutine thereby gives compleat, valid, historical continuity of
date-stamp conversion until 31.dec.9999 in the relevant epoch.
Because of its initial overlap with the historical year, a 93 addend is
to apply till December 31st. From January 1st, a 94 addend applies till
the end of the Old Style year on March 24th or also till the end of the
Byzantine year on August 31st. Month-numbers remain defined in terms of
the historical year for both (as for calendars where N%=300).
--
REFERENCES http://oz.ccnet.us/dayofweek/
http://www.guernsey.net/~sgibbs/roman.html
http://en.wikipedia.org/wiki/Zeller%27s_congruence
http://www.tondering.dk/claus/cal/node3.html#SECTION00360000000000000000
babwani-congruence.blogspot.com/search/label/Frequently%20AskeD$20Questions
[toc] | [next] | [standalone]
| From | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| Date | 2011-03-15 12:00 +0000 |
| Message-ID | <ilnkdk$pli$1@droog.sdf-eu.org> |
| In reply to | #70 |
>
> Because of its initial overlap with the historical year, a 93 addend is
> to apply till December 31st. From January 1st, a 94 addend applies till
. . .
>REFERENCES http://oz.ccnet.us/dayofweek/
. . .
The addends should be 19300 & 19400 for integer arithmetic,
rather than those for a calculator as used in the 1st reference.
Also, here's the missing link to Mike Keith's method:
http://www.merlyn.demon.co.uk/zel-like.htm#Keith
[toc] | [prev] | [next] | [standalone]
| From | "Brian Gaff" <Briang1@blueyonder.co.uk> |
|---|---|
| Date | 2011-03-16 10:15 +0000 |
| Message-ID | <ilq2ji$qnv$1@news.eternal-september.org> |
| In reply to | #70 |
Thats no zx basic I know. Brian -- Brian Gaff - briang1@blueyonder.co.uk Note:- In order to reduce spam, any email without 'Brian Gaff' in the display name may be lost. Blind user, so no pictures please! "Milton Lachman" <lachman@ebony.ppc.ubc.ca> wrote in message news:ilnet7$svj$1@droog.sdf-eu.org... > HOW TO COMPUTE THE DAY OF THE WEEK FOR DATE-STAMPS 10010101 TO 99991231 > - using Hans Lachman's Method of Congruence as generalised below - > > > Strictly adhering to Lachman's Maxim (Complexity is a diseconomy of > scale), > this method is designed to run superbly as a stand-alone subroutine, when > the most basic of computer is the only resource--meaning no values needed > from user tables or system calls, and no floating point variables. > > Although using a processor more sophisticated than found on four-function > calculators, this method is simpler to execute than Hans' original Method > of Congruence needing manipulation of data by numerically competent users. > It succeeds where other Methods do not when computing the day of the week > even on lowly Sinclair ZX BASIC: having no need of extra instructions for > data stored in tables as in Babwani's Method nor for redundant operations > as in Zeller's or Tondering's--nor even a C compiler running on a bloated > development system as in Mike Keith's-- yet doing more in under 12 lines. > > Given: > > D$(8) as a Date-stamp YYYYMMDD in basic ISO format, > N% as its amount of shifting, > & F% as a false flag for non-Gregorian calendars: > 300 0 Julian (historical) > 301 0 Byzantine > 325 0 Old-Style > 300 50 Gregorian (historical); > K% as an addend (19300 for integer arithmetic) > X% as a multiplier (256 for integer arithmetic) > > the Sinclair BASIC subroutine below is to compute: > > y% as the Year > m% as the month > m$ whereby m$(2TO3)=MonthIndex > d% as the day's number within the month > i% as an increment to K% > w% as the ISO-compatible number of the corresponding weekday: > Sun=0 Mon=1 Tue=2 Wed=3 Thu=4 Fri=5 Sat=6 > > > REM Step 0 - isolate components of & offset the Date-stamp: > LET y%=D$(1TO4) : m%=D$(5TO6) : d%=D$(7TO8) : s$=D$-N% : i%=F%+F% > IF N%=301 THEN > IF m%>8 THEN LET s$(1TO4)=s$(1TO4)-1 > IF s$(5TO6)<6 THEN LET i%=100 > END IF > IF N%=325 THEN > IF s$(5TO8)>9775 THEN LET i%=100 > IF s$(5TO8)>9975 THEN LET s$(1TO4)=s$(1TO4)+1 > END IF > > REM Step 1 - compute the MonthIndex: > LET m$=m%*X% + K% + i% > > REM Step 2 - compute the weekday-number: > LET w%=(s$(1TO4)DIV4 + y% + m$(2TO3) + d% + F%*s$(1TO2)DIV8 + F%)MOD7 > > > The subroutine is streamlined such that parameters are to be passed in > proper format. For example, one must pass a flag of 50 for Gregorian > dates as of 15.oct.1582 A.D, & 0 for non-Gregorian as of 1.jan.1001: > A.D. for Julian & Old Style calendars; & A.M. for Byzantine calendars. > The subroutine thereby gives compleat, valid, historical continuity of > date-stamp conversion until 31.dec.9999 in the relevant epoch. > > Because of its initial overlap with the historical year, a 93 addend is > to apply till December 31st. From January 1st, a 94 addend applies till > the end of the Old Style year on March 24th or also till the end of the > Byzantine year on August 31st. Month-numbers remain defined in terms of > the historical year for both (as for calendars where N%=300). > > > -- > > REFERENCES http://oz.ccnet.us/dayofweek/ > http://www.guernsey.net/~sgibbs/roman.html > http://en.wikipedia.org/wiki/Zeller%27s_congruence > http://www.tondering.dk/claus/cal/node3.html#SECTION00360000000000000000 > babwani-congruence.blogspot.com/search/label/Frequently%20AskeD$20Questions > >
[toc] | [prev] | [next] | [standalone]
| From | spike1@freenet.co.uk |
|---|---|
| Date | 2011-03-16 12:26 +0000 |
| Message-ID | <esm658-5lc.ln1@librarian.sky.com> |
| In reply to | #73 |
And verily, didst Brian Gaff <Briang1@blueyonder.co.uk> hastily babble thusly: > Thats no zx basic I know. I doubt he's even seen a sinclair machine. -- | |What to do if you find yourself stuck in a crack| | spike1@freenet.co.uk |in the ground beneath a giant boulder, which you| | |can't move, with no hope of rescue. | | Andrew Halliwell BSc |Consider how lucky you are that life has been | | in |good to you so far... | | Computer Science | -The BOOK, Hitch-hiker's guide to the galaxy.|
[toc] | [prev] | [next] | [standalone]
| From | "Brian Gaff" <Briang1@blueyonder.co.uk> |
|---|---|
| Date | 2011-03-17 08:36 +0000 |
| Message-ID | <ilsh6i$6ht$1@news.eternal-september.org> |
| In reply to | #74 |
I was just trying to figure out what the point of posting it here actually was. There are lots of bits of software to work out dates after all, it was one of the first things we all wrote and used in those early days. Plotting bio rhythms and making appointment books etc. Brian -- Brian Gaff - briang1@blueyonder.co.uk Note:- In order to reduce spam, any email without 'Brian Gaff' in the display name may be lost. Blind user, so no pictures please! <spike1@freenet.co.uk> wrote in message news:esm658-5lc.ln1@librarian.sky.com... > And verily, didst Brian Gaff <Briang1@blueyonder.co.uk> hastily babble > thusly: >> Thats no zx basic I know. > > I doubt he's even seen a sinclair machine. > -- > | |What to do if you find yourself stuck in a > crack| > | spike1@freenet.co.uk |in the ground beneath a giant boulder, which > you| > | |can't move, with no hope of rescue. > | > | Andrew Halliwell BSc |Consider how lucky you are that life has been > | > | in |good to you so far... > | > | Computer Science | -The BOOK, Hitch-hiker's guide to the > galaxy.|
[toc] | [prev] | [next] | [standalone]
| From | spike1@freenet.co.uk |
|---|---|
| Date | 2011-03-17 09:36 +0000 |
| Message-ID | <da1958-5lc.ln1@librarian.sky.com> |
| In reply to | #75 |
Someone with too much ego and not enough ability to filter what's appropriate for what group? Look at me! I'm posting something! bow down to my magnificence! What do you mean it's not sinclair BASIC? what does that matter? it was posted by me! MEMEME!! etc. And verily, didst Brian Gaff <Briang1@blueyonder.co.uk> hastily babble thusly: > I was just trying to figure out what the point of posting it here actually > was. There are lots of bits of software to work out dates after all, it was > one of the first things we all wrote and used in those early days. > Plotting bio rhythms and making appointment books etc. -- | spike1@freenet.co.uk | Windows95 (noun): 32 bit extensions and a | | | graphical shell for a 16 bit patch to an 8 bit | | Andrew Halliwell BSc | operating system originally coded for a 4 bit | | in |microprocessor, written by a 2 bit company, that| | Computer Science | can't stand 1 bit of competition. |
[toc] | [prev] | [next] | [standalone]
| From | korax1214 <korax1214@gmail.com> |
|---|---|
| Date | 2011-03-17 16:15 -0700 |
| Message-ID | <7cb00edb-65ce-4721-bc4a-cb86d9254574@dr5g2000vbb.googlegroups.com> |
| In reply to | #76 |
You should see the state alt.games.mame is currently in, due to an egomaniacal (and extremely rude) idiot who, amongst other things, reckons he knows better than anyone else (including people who have been there for *years*) what is and isn't acceptable on that group. Of course, having been there about two months now, by now he's talking solely to himself, everyone else having killfiled him. :-)
[toc] | [prev] | [next] | [standalone]
| From | jgharston <jgh@arcade.demon.co.uk> |
|---|---|
| Date | 2011-03-17 17:49 -0700 |
| Message-ID | <b5c1939b-bab7-42e8-ad15-fdd34f600e9c@x18g2000yqe.googlegroups.com> |
| In reply to | #78 |
REM FNDate_DayOfWeek(day%,month%,year%) - return day of week for
supplied date
REM 1=Sunday, 7=Saturday
REM
--------------------------------------------------------------------------
:
DEFFNDate_DayOfWeek(d%,m%,y%):y%=y%MOD400
=(y%*365.25+m%*30+d%+VALMID$("120112234455",m%,1)+(y%MOD4)=0)-((y
%-1)DIV100)-(m%>2AND((y%MOD4)=0AND(y%MOD100)<>0ORy%=0))+3)MOD7+1
Conversion to Spectrum Basic is left as an exercise for the reader.
JGH - mdfs.net/BLib
[toc] | [prev] | [next] | [standalone]
| From | "Brian Gaff" <Briang1@blueyonder.co.uk> |
|---|---|
| Date | 2011-03-18 07:10 +0000 |
| Message-ID | <ilv0gb$ft9$1@news.eternal-september.org> |
| In reply to | #79 |
With due respect, that is not what you originally said.
I'd suggest that the whole point is that this is a Sinclair group, and one
would expect it to contain information that was directly usable on said
machines.
The string slicing, for example is much more logical in zx, not using
these crazy mid$ rubbish. and what are oll those percent signs about.
Why use endif when zx basic can do computed gosubsa nd gotos?
Brian
--
Brian Gaff....Note, this account does not accept Bcc: email.
graphics are great, but the blind can't hear them
Email: briang1@blueyonder.co.uk
______________________________________________________________________________________________________________
"jgharston" <jgh@arcade.demon.co.uk> wrote in message
news:b5c1939b-bab7-42e8-ad15-fdd34f600e9c@x18g2000yqe.googlegroups.com...
> REM FNDate_DayOfWeek(day%,month%,year%) - return day of week for
> supplied date
> REM 1=Sunday, 7=Saturday
> REM
> --------------------------------------------------------------------------
> :
> DEFFNDate_DayOfWeek(d%,m%,y%):y%=y%MOD400
> =(y%*365.25+m%*30+d%+VALMID$("120112234455",m%,1)+(y%MOD4)=0)-((y
> %-1)DIV100)-(m%>2AND((y%MOD4)=0AND(y%MOD100)<>0ORy%=0))+3)MOD7+1
>
> Conversion to Spectrum Basic is left as an exercise for the reader.
>
> JGH - mdfs.net/BLib
[toc] | [prev] | [next] | [standalone]
| From | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| Date | 2011-03-23 18:06 +0000 |
| Message-ID | <imdcr7$h32$1@droog.sdf-eu.org> |
| In reply to | #75 |
Brian Gaff - briang1@blueyonder.co.uk wrote ><spike1@freenet.co.uk> wrote in message >> And verily, didst Brian Gaff <Briang1@blueyonder.co.uk> hastily babble >> thusly: >>> Thats no zx basic I know. >> >> I doubt he's even seen a sinclair machine. > >I was just trying to figure out what the point of posting it here actually >was. ZX BASIC was on my 1st Sinclair machine, which I had bought instead of a programmable calculator to crunch lab data. But that was too long ago for me to remember 'computed gosubs'. I soon upgraded to a QL. So I posted a simplified superBASIC routine, w/the expectation that it could easily be adapted to ZX BASIC if need be, including the END IFs & the integer variables ending in %. In any case, the routine is intended to convert NON-Gregorian dates, the kind that one will eventually encounter in one's family tree. See my posts on the soc.genealogy groups for converting Julian & Old-Style dates without a computer. And just in the nick of time for the 1st of April, jgharston's BBC BASIC routine--esp. having you convert mid$ into spectrum BASIC-- is merely a troll.
[toc] | [prev] | [next] | [standalone]
| From | jgharston <jgh@arcade.demon.co.uk> |
|---|---|
| Date | 2011-03-24 16:04 -0700 |
| Message-ID | <ecd7488e-fafd-4723-811e-303d95ed6df7@g10g2000yqj.googlegroups.com> |
| In reply to | #100 |
Milton Lachman wrote: > And just in the nick of time for the 1st of April, jgharston's BBC > BASIC routine--esp. having you convert mid$ into spectrum BASIC-- > is merely a troll. It wasn't a troll. You provided some code with the unstated expectation that people convert it to Spectrum Basic. I provided some prewritten, tested and extensively-used code with the _explicit_ statement that it could be converted into Spectrum Basic. I may eventially get around to doing that conversion myself, but would have no objection to somebody else doing it before me. Additionally, my code can actually run on the Spectrum if you choose to use BBC BASIC for the Spectrum. mdfs.net/bbcbasic/Spectrum JGH
[toc] | [prev] | [next] | [standalone]
| From | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| Date | 2011-03-27 16:48 +0000 |
| Message-ID | <imnpp1$204$1@droog.sdf-eu.org> |
| In reply to | #102 |
> Re: Conversion of ISO Date-stamps into Weekday Numbers > From: jgharston <jgh@arcade.demon.co.uk> >Milton Lachman wrote: >> And just in the nick of time for the 1st of April, jgharston's BBC >> BASIC routine--esp. having you convert mid$ into spectrum BASIC-- >> is merely a troll. > >It wasn't a troll. You provided some code with the unstated expectation >that people convert it to Spectrum Basic. I provided some prewritten, >tested and extensively-used code with the _explicit_ statement that it >could be converted into Spectrum Basic. I may eventially get around to >doing that conversion myself, but would have no objection to somebody >else doing it before me. It's a troll to a certain %, given that your code doesn't convert ISO date-stamps, as explicitly stated, nor does it convert NON- Gregorian dates, as also for the original post. The follow-up to it was posted on the Ides of March on the Gregorian calendar instead of tomorrow, which is the anniversary of Julius Caesar's death on his Julian calendar--as egregious a faux pas as not posting it in ZX BASIC on the 30th anniversary of the ZX 81--but this thread started last year as an academic exercise to exclusively use string variables in superBASIC. Therefore the thread is meant for the QL, which qualifies as a "sinclair machine" even if not a ZX 83 officially.
[toc] | [prev] | [next] | [standalone]
| From | lachman@ebony.ppc.ubc.ca (Milton Lachman) |
|---|---|
| Date | 2011-03-23 21:32 +0000 |
| Message-ID | <imdosi$lgj$1@droog.sdf-eu.org> |
| In reply to | #75 |
From: "Brian Gaff" <Briang1@blueyonder.co.uk> ><spike1@freenet.co.uk> wrote in message >> And verily, didst Brian Gaff <Briang1@blueyonder.co.uk> hastily babble >> thusly: >>> Thats no zx basic I know. >> >> I doubt he's even seen a sinclair machine. > >I was just trying to figure out what the point of posting it here actually >was. The in-house name of the QL was the ZX 83; I only claimed that the METHOD was designed with ZX BASIC in mind; and I also dropped in a claim of "superbly" as a hint that the routine was written in superBASIC--which qualifies as "Sinclair BASIC" as claimed for the routine. ZX BASIC was on my 1st Sinclair machine, which I had bought instead of a programmable calculator to crunch lab data. But that was too long ago for me to remember 'computed gosubs'. I soon upgraded to a QL. I posted a simplified superBASIC routine, w/the expectation that it could easily be adapted to ZX BASIC if need be, including the END IFs & the integer variables ending in %. In any case, the routine is intended to convert NON-Gregorian dates, the kind that one will eventually encounter in one's family tree. See my posts on the soc.genealogy groups for converting Julian & Old-Style dates without a computer. And just in the nick of time for the 1st of April, jgharston's BBC BASIC routine--esp. having you convert mid$ into spectrum BASIC-- is merely a troll.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.sinclair
csiph-web