This program performs calculations with calendar dates and complies with ISO 8601, which is currently used in European countries. The Gregorian calendar and the date range 1.01/1600...31.12/2800 are used, which provides modern practical needs.
Calculated parameters: 1) determining the day of the week according to the date; 2) the distance in days between dates; 3) getting the date by adding or subtracting the specified number of days; 4) each date is accompanied by the week number, the number of days from the beginning (or to the end) of the year for each date; 5) all calculations take into account leap years.
Results provide complete information about the dates obtained, regardless of the content of the original query.
DATEWEEK.g1m 2.95_kb
Edit 2020.1110 updated the link. "Error messages" have been edited.
Edit 2020.1111 fixed the bug: when December 31 of a leap year fell on a Monday, the week number for that day was calculated incorrectly.
Edit 2020.1113 added the input form option d.mm or m.dd for dates. It could be set in the first line of the program text: 0➝S is for d.mm and 1➝S is for m.dd. Since now, you may omit the "YYYY" input in any date. The value for the "year" is taken sequentially from the last existing date.
For example, valid inputs for m.dd form:
5.282018,7.30 8.05,6.18 12.28,10.152012 5.29,–185 and so on.
Single input without a comma (××.×× ) is also valid.
Edit 2020.1118 added the convenience to select the first day of the week. It is set in the first line of the program text.
0➝Z (MON=1...SUN=7); 1➝Z (SUN=1...SAT=7); 2➝Z (SAT=1...FRI=7). By default S=0, Z=0.
In all cases, the calculation of the week number is based on the standard rule:
the first week of the ISO calendar year is the earliest week that contains at least four days of the month of January. The last week of the ISO calendar year is the last week that contains at least four days of the month of December.
Quick guide
When the program starts, the display shows a reminder of the limit range in the form of two end dates.
For the "D.MM(YYYY) Or DAYS ?" query, enter the date(s) or number of days.
1) Input: 7.032019,15.12
(when entering, we use the format dd.mmyyyy, if 0➝S is set)
Output: 2019.0307__THU=4
(when output, the date format will be as follows: yyyy.mmdd)
66/299___W=10
(how many days have passed since the beginning of the year/how many days are left until the end of the year, and the week number for this date)
2019.1215__SUN=7
349/16___W=50
DAYS=283 (distance between the last two dates)
2) I: 15.022002, -(7×23+3)
(23 weeks and 3 days backwards from the specified date. Don`t confuse the negative "( - )" sign with the subtraction sign "–")
O: 2002.0215__FRI=5
46/319___W=7
2001.0904__TUE=2
247/118__W=36
DAYS=-164
3) I: 55 (55 days onwards from the last date)
O: 2001.0904__TUE=2
247/118__W=36
2001.1029__MON=1
302/63___W=44
DAYS=55
4) I: -55 (go back to the starting date)
5) I: 1.012021 (we will get information about this date, but the calculations will also use the last obtained date)
O: 2001.0904__TUE=2
247/118__W=36
2021.0101__FRI=5
1/364____W=53
DAYS=7059
notes:
1.1219 means 1.121900, 1.1220257876 means 1.122025.
182.151988 causes error message "MONTH ERROR". The program reports the first error encountered in typing from right to left.
[0] stops program.
Used memory: Y1...Y6 graph vars; A...Z alpha mem.; List_1...List_3; Str_1, Str_2.
Edited by Hlib2, 18 November 2020 - 08:12 PM.