Jump to content



Photo
- - - - -

Calendar calculations

fx-9860gii date calculations

  • Please log in to reply
1 reply to this topic

#1 Hlib2

Hlib2

    Casio Freak

  • Members
  • PipPipPipPip
  • 139 posts
  • Gender:Male
  • Location:Ukraine
  • Interests:industrial electronics,
    graphing calculators

  • Calculators:
    fx-9860GII-2,
    cfx-9850GC+,
    fx-9750G+, graph_100+,
    fx-9750GII, fx-991DE_X,
    ti-83+_SE, ti-84+, ti-85,
    ti-89_Titanium,
    ti-voyage200.

Posted 06 November 2020 - 04:27 PM

The program is designed for calculators that have String functions: e.g. fx-9750gii/giii, fx-9860gii/giii. It is not intended for C.BASIC, as it uses the "Cuml" function, which is not yet implemented in that application. This causes the calculator to freeze with the loss of the last unsaved RAM state.
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.

32299372_m.png 32299389_m.png

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 EXE 8.05,6.18 EXE 12.28,10.152012 EXE 5.29,–185 EXE and so on.
Single input without a comma (××.×× EXE) 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 EXE
(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) EXE
(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 EXE (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 EXE (go back to the starting date)
5) I: 1.012021 EXE (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
All attributes must be entered for each date, otherwise there will be an error message and the program will return to the initial state.
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] EXE 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.


#2 Hlib2

Hlib2

    Casio Freak

  • Members
  • PipPipPipPip
  • 139 posts
  • Gender:Male
  • Location:Ukraine
  • Interests:industrial electronics,
    graphing calculators

  • Calculators:
    fx-9860GII-2,
    cfx-9850GC+,
    fx-9750G+, graph_100+,
    fx-9750GII, fx-991DE_X,
    ti-83+_SE, ti-84+, ti-85,
    ti-89_Titanium,
    ti-voyage200.

Posted 11 November 2020 - 04:50 PM

Improved versions of the DATEWEEK program.

1) the DDTW1 is designed for the fx-9750g/9850g models. The parameter "EngOff" for displaying numbers in these calculators is set manually.
DDTW1.g1m 2.3_kb

2) the DDTW2 is designed for the fx-9750gii/9860g(ii)/××××giii models and is compatible with the C.BASIC app.
DDTW2.g1m 2.4_kb

3) Edit 2020.1113. The DDTW3 optimized version,
for gii/giii only (is not compatible with C.BASIC). Runs 25% faster, than "DDTW2".
DDTW3.g1m 2.3_kb

To simplify the work with entries, a comma is no longer supported: instead of
"date1","date2"EXE or "date","days"EXE should enter
"date1"EXE"date2"EXE or "date"EXE"days"EXE.
The entering format d.mm or m.dd for dates should be set in the first line of the program text: 0➝S is for d.mm and 1➝S is for m.dd. When entering the "YYYY" parameter (11.052015), you can omit it, then the value for the current year is taken from the last date on the display. It should be remembered that 8.2 is treated as 8.20 etc.
Used memory: Y1...Y6; List_2, List_3; A~Z.

note: due to a bug in C.BASIC, values for some years, such as 2035 and 2040, are converted to 2034 and 2039 when entered. The expression 1.012040➝X: Int (10^4×Frac (10^2×Frac X) in C.BASIC returns the result 2039 instead of 2040.
To enter date 1.012040 do:
1.012040 EXE 365 EXE
In all other cases, the "DDTW2" program works in the C.BASIC environment without errors.

Edit 2020.1118 (for all three programs) 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.

Edited by Hlib2, 18 November 2020 - 08:17 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users