N° of the week from a date
11-01-2015, 06:15 PM
Post: #1
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
N° of the week from a date
HI,

Here is an another little, sometime usefull to know in which week will occur an evenement. Th formulae is :

N° week= IP[DOW(1/1/YYYY)+DOY(JJ,MMYYYY)+5]/7 - [IP(DOW(1/1/YYYY)/5].

Code:
 LBL'NUW' XEQ'001' WDAY STO I x<>Z XEQ'001' [delta]DAYS +/- INC X RCL I + 5 + 7 / IP RCL I 5 / IP - RTN LBL'001' ENTER YEAR #001 #001 [->]DATE RTN END

It is according to ISO 8601, so for old calendars the result may vari +/- 1 week.

17/04/1982----> 15 (week 15)
30/06/1950----> 26 (week 26)

Gérard.

Gérard.
11-02-2015, 10:03 PM (This post was last modified: 11-02-2015 10:22 PM by Dieter.)
Post: #2
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: N° of the week from a date
(11-01-2015 06:15 PM)ggauny@live.fr Wrote:  Here is an another little, sometime usefull to know in which week will occur an evenement.

You should have taken part in the last New Year's programming challenge. ;-)
There also is a quite promising formula mentioned in the link at message #26/27 (en français ;-)).

Dieter
11-03-2015, 07:09 PM
Post: #3
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi Dieter,

I was not knowing this thread. Is my routine agree you ?
Do you like my routine ? If yes i'm proud.

I have posted a new little routine that return the date from a DOY. She is in the test forum. Now I know it is the right place.

I think I will finish tomorow the second routine for Easter in Gregorian.

Have a good night.

Gérard.

Gérard.
11-03-2015, 07:59 PM
Post: #4
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: N° of the week from a date
(11-03-2015 07:09 PM)ggauny@live.fr Wrote:  I was not knowing this thread. Is my routine agree you ?
Do you like my routine ? If yes i'm proud.

Your program takes advantage of some techniques you did not use before, for instance INC and integer constants. So that's indeed a step forward. Another step could include using RCL-arithmetice (e.g. RCL+I instead of RCL I +) and integer division (7 IDIV instead of 7 / IP).

But I'm not sure if the formula is correct. I tried the sample cases in the mentioned New Year's challenge thread, and some results are wrong. For instance, the program may return week 0 (try 2 Jan 2010). Or Monday, 31 Dec 2012 returns week 53. What about the elegant formula on that French website?

(11-03-2015 07:09 PM)ggauny@live.fr Wrote:  I have posted a new little routine that return the date from a DOY. She is in the test forum. Now I know it is the right place.

The test forum ist for testing forum features. ;-)

Dieter
11-04-2015, 07:54 AM
Post: #5
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi,

Thanks for encouragements ! I know that if the 01/01/yyyy biguin a thursday (jeudi), the n° of week is 1, if there is less than 4 days in the biguining year, the week is noted "0". Then at the end of the year we, sometimes, have a "53" week, wich is combinated with the following first week of the following YEAR+1.

In french it si more easy to explain,

On peut trouver W = 0 dans le cas du ou des premiers jours de l’année lorsque la première semaine (incomplète) de janvier a 1, 2, ou 3 jours ; ces quelques jours appartiennent alors a la dernière semaine, numérotée 52 ou 53, de l’année précédente.

De même, le 29 / 12 / m -si c’est un lundi- , le 30 / 12 / m -si c’est un lundi ou un mardi- , le 31 / 12 / m -si c’est un lundi, un mardi ou un mercredi- appartienent à la semaine 1 de l’année m + 1 ,

Sorry to write in french, but it is obligation for me in this case.

As an an example : on the official calendar of post in france, I can see that :

1/01/2015 is thursday, 2/02/2015 is friday, 3/01/2015 is saturday and 4/01/2015 is sunday, well there are at least 4 days then the week is officialy noted as n°1.
The last week of 2015 has 4 days (28,29,30,31 : monday, thuesday, wednessday and thursday) is noted of course n°53. On the other hand, in 2016 there will be only 3 days on biguining year (Friday 1, saturday 2 and sunday 3) so the first week of 2016 will be of course noted, officialy on french calendar, n° 0.

I've attempted to put photos of the calendar, but too bigs for our forum.

Good day

Gérard.

Gérard.
11-04-2015, 08:20 AM
Post: #6
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Would you have a look at attachements ?

Gérard.
11-04-2015, 10:15 AM
Post: #7
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date

Gérard.
11-06-2015, 07:01 AM
Post: #8
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: N° of the week from a date
(11-04-2015 07:54 AM)ggauny@live.fr Wrote:  Thanks for encouragements ! I know that if the 01/01/yyyy biguin a thursday (jeudi), the n° of week is 1, if there is less than 4 days in the biguining year, the week is noted "0". Then at the end of the year we, sometimes, have a "53" week, wich is combinated with the following first week of the following YEAR+1.

Sorry, but there is no week 0. Weeks have numbers between 1 and 53. The rule is quite simple: If a week falls both into the old and the new year, it counts either as the last week (52 or 53) of the old year or week 1 of the new year – depending on which year has more days of that week.

This is also shown in your calendar examples. There really is no week 0. ;-)

(11-04-2015 07:54 AM)ggauny@live.fr Wrote:  The last week of 2015 has 4 days (28,29,30,31 : monday, thuesday, wednessday and thursday) is noted of course n°53.

Right. It has at least four days in it, i.e. the major part of a week.

(11-04-2015 07:54 AM)ggauny@live.fr Wrote:  On the other hand, in 2016 there will be only 3 days on biguining year (Friday 1, saturday 2 and sunday 3) so the first week of 2016 will be of course noted, officialy on french calendar, n° 0.

There is no week 0. At least the ISO standard does not know of such a week number. This week (monday through sunday) still is week 53 of 2015. That week starts in 2015 and ends in 2016. Yes, the three first days of january 2016 count as week 53 of 2015.

(11-04-2015 07:54 AM)ggauny@live.fr Wrote:  I've attempted to put photos of the calendar, but too bigs for our forum.

The screenshots also show no week 0. Just week 53/2015 (beginning in 2015 and ending in 2016) and week 1/2016 (starting on 4 January).

Once again: the ISO rule really is very simple. If the major part of a week falls into the previous year, that's the last week (52 or 53) of that year. If the major part falls into the new year, that's its week 1.

Dieter
11-06-2015, 07:27 AM
Post: #9
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi,

Ok, I'm going to update my routine.

Have a good day.

Gérard.

Gérard.
11-06-2015, 07:42 AM
Post: #10
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi,

I would like explain why I use of week "0". In an old french text in calculating calendar, I saw this :
Code:
 1. Postulat  Nous adopterons la règle suivante : Si la première semaine de l’année est incomplète (c’est le cas six fois sur sept ; quand le premier janvier n’est pas un lundi), elle est numérotée 1 dès lors qu’elle a au moins quatre jours, 0 sinon. Ainsi, le premier lundi de l’année appartient à la semaine 2 lorsque l’année commence un mardi, un mercredi, ou un jeudi ; il appartient à la semaine 1 lorsque le premier janvier est un vendredi, un samedi, un dimanche... ou un lundi.

But you have saw that in my Excel calendar I DON'T write week "0", it would be a no-sens, I agree. In my routine it was a shortcut to indicate that a day IS NOT in the first week but in the last week of year-1.

I will update my routine to keep care of your comment, which is normal !

Gérard.

Gérard.
11-06-2015, 08:10 PM
Post: #11
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: N° of the week from a date
(11-06-2015 07:42 AM)ggauny@live.fr Wrote:  I would like explain why I use of week "0". In an old french text in calculating calendar, I saw this :

With all due respect for old French calendar texts: today ISO rules. And there is no week 0 defined in ISO 8601.

Quote:Si la première semaine de l’année est incomplète (c’est le cas six fois sur sept ; quand le premier janvier n’est pas un lundi), elle est numérotée 1 dès lors qu’elle a au moins quatre jours,

Correct.

Quote: 0 sinon.

Not correct.

(11-06-2015 07:42 AM)ggauny@live.fr Wrote:  But you have saw that in my Excel calendar I DON'T write week "0", it would be a no-sens, I agree. In my routine it was a shortcut to indicate that a day IS NOT in the first week but in the last week of year-1.

Well, exactly this is one of the tricky parts of the program: finding out whether the last week of the previous year is week 52 or 53. ;-)

(11-06-2015 07:42 AM)ggauny@live.fr Wrote:  I will update my routine to keep care of your comment, which is normal !

What do you think about the formula in the French text mentioned in the old thread from January? It looks quite straightforward and elegant, but I haven't checked it yet.

Dieter
11-10-2015, 12:40 PM
Post: #12
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi,

I think it's a promising formulae, she is via JDN. Mine not and may be she is a little bit less complicated.

But I'am waiting for the end of this challenge : The "winner is...." not to have a winner medal but for the "best" program for experts.

On my 34s, I've adopted your program with optimisation of the LBL 53, on my two Prime, the Damien program.

BTW, I've two emulators of 34s, the GUI and the QT . But it seem they have not the same libruary. My question is that in the GUI I've many programs that I can't put into the QT. I've tryed with copy raw and past raw, not work. Because they are virtuals on the same PC, it should be a trick to copy one into the other ?
Of course I re-copying by hand in the QT.

Gérard.

Gérard.
11-10-2015, 02:35 PM
Post: #13
 fhub Member Posts: 188 Joined: Dec 2013
RE: N° of the week from a date
(11-10-2015 12:40 PM)ggauny@live.fr Wrote:  BTW, I've two emulators of 34s, the GUI and the QT . But it seem they have not the same libruary. My question is that in the GUI I've many programs that I can't put into the QT. I've tryed with copy raw and past raw, not work. Because they are virtuals on the same PC, it should be a trick to copy one into the other ?
Of course I re-copying by hand in the QT.
Hi Gérard,

both (the GUI and the QT) have the same 2 files:
1) wp34s.dat for the emulator RAM (memory and status)
2) wp34s-lib.dat for the emulator ROM (library)
and the format for both emulator version is exactly the same.

So if you want to have everything that from your GUI version also in your QT version, then you can just copy these 2 files from the GUI to the QT emulator.
For the GUI these 2 files are usually in the same folder as the emulator itself, in the QT version you can specify the location of these files in the options menu - just look where they are in your installation, and then you know where to copy these 2 files.

Franz
11-10-2015, 03:10 PM
Post: #14
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Hi Franz,

I'm very happy to read you.
I'm going to try this.

Thank you

Gérard.

Gérard.
11-10-2015, 05:59 PM
Post: #15
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
Quote:So if you want to have everything that from your GUI version also in your QT version, then you can just copy these 2 files from the GUI to the QT emulator.
For the GUI these 2 files are usually in the same folder as the emulator itself, in the QT version you can specify the location of these files in the options menu - just look where they are in your installation, and then you know where to copy these 2 files.

Franz

Hi,
After (a long time ) cut it off by hands my last hairs, I have at the end found how to put my programs into the new emulator QT.

Your advertising is very good, may be somes others members will applicate.

gérard.

PS : Because I don't know how to write "fhub wrote--->", I do like this, and it's work.

Gérard.
11-10-2015, 09:28 PM
Post: #16
 Marcus von Cube Senior Member Posts: 760 Joined: Dec 2013
RE: N° of the week from a date
(11-10-2015 05:59 PM)ggauny@live.fr Wrote:  PS : Because I don't know how to write "fhub wrote--->", I do like this, and it's work.

Just use the button labeled "quote" below the message you want to reply to.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
11-10-2015, 10:02 PM (This post was last modified: 11-10-2015 10:02 PM by walter b.)
Post: #17
 walter b On Vacation Posts: 1,957 Joined: Dec 2013
RE: N° of the week from a date
Together with "Threaded Mode" it takes care for proper sorting of messages as well.

d:-)
11-10-2015, 10:07 PM
Post: #18
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
(11-10-2015 09:28 PM)Marcus von Cube Wrote:
(11-10-2015 05:59 PM)ggauny@live.fr Wrote:  PS : Because I don't know how to write "fhub wrote--->", I do like this, and it's work.

Just use the button labeled "quote" below the message you want to reply to.

Bonsoir,

Vous parlez très bien français. Merci de vouloir bien m'aider. En américain, moi je ne comprends rien du tout et même ma femme, ayant pourtant son BAC (abitur) hésite parfois dans les traduc.tions !

Je vous souhaite la bonne nuit

Gérard.

Gérard.
11-10-2015, 10:23 PM
Post: #19
 ggauny@live.fr Senior Member Posts: 489 Joined: Nov 2014
RE: N° of the week from a date
(11-10-2015 10:02 PM)walter b Wrote:  Together with "Threaded Mode" it takes care for proper sorting of messages as well.

d:-)

Dear Sir,

I'm not sur of what it is the meaning of your text, and my wife too.

But I thank you to write to I.

We are trying to translate in french, here google traduction no help us !

Have a good night Dear Sir

Gérard.

Gérard.
11-11-2015, 07:56 AM
Post: #20
 walter b On Vacation Posts: 1,957 Joined: Dec 2013
RE: N° of the week from a date
Voyez, monsieur, s'il vous plait: il y'a un button "Threaded Mode" (top right of each post). Please click on it and note the difference in appearance of the thread you are looking at. Enjoy!

d:-)
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)