I'm trying jayna, this date~time~calender coding is a challenge for me to try to figure out... I'm doing my best at trying to get this set up in code, as best as I can, lol. So, forgive the ugliness of it, it's what I've been able to come up with so far in design.
I'm sure date~time~calender stuff is pretty basic programming, but I'm still very new to coding~programming, and so this is a challenge for me to code-logic understand and to figure it's design out... sighs.
-----------
actually, in the poor (yes, I know this can be coded better, maybe I can make something better if I keep working at it, but this is what I was able to do for now) coding that I have, these two functions are needed for it to work, and they're not exactly the same (take a closer look at them, in how they're needed for what is my coding design).
using the simple testing of plugging in numbers:
year = 0
a_function:
0 / 4 = 0 -> old_leap_year = 0 and new_leap_year = 0 + 4
year = 0
old_leap_year = 0
new_leap_year = 4
-----------------
year = 4
a_function:
4 / 4 = 1 -> old_leap_year = 4 and new_leap_year = 0 + 4
year = 4
old_leap_year = 4
new_leap_year = 8
-----------------
year = 8
a_function:
8 / 4 = 2 -> old_leap_year = 8 and new_leap_year = 0 + 4
year = 8
old_leap_year = 8
new_leap_year = 12
-------------------
year = 1
a_function:
1 / 4 = 0.25 -> b_function
b_function:
1 + 1 = 2
2 / 4 = 0.50 -> b_function
2 + 1 = 3
3 / 4 = 0.75 -> b_function
3 + 1 = 4
4 / 4 = 1
year = 1
+ "function resultant years"
NEW_leap_year = 4
year = 1
OLD_leap_year = 4 - 4 = 0
------------------
year = 5
a_function:
5 / 4 = 1.25 -> b_function
b_function:
5 + 1 = 6
6 / 4 = 1.50 -> b_function
6 + 1 = 7
7 / 4 = 1.75 -> b_function
7 + 1 = 8
8 / 4 = 2
year = 5
+ "function resultant years"
NEW_leap_year = 8
year = 5
OLD_leap_year = 8 - 4 = 4
--------
year = 7
a_function:
7 / 4 = 1.75 -> b_function
b_function:
7 + 1 = 8
8 / 4 = 2
year = 7
+ "function resultant years"
NEW_leap_year = 8
year = 7
OLD_leap_year = 8 - 4 = 4
---------
you're probably wondering why the "old_leap" matters if the "year" is already exceeding it....
remember that the "change" method that I'm using is this:
year = 0
old_leap = 0
new_leap = old_leap + 4
if (year = new_leap) {
-> old_leap = year
-> new_leap = old_leap + 4
}
as this allows me do the easy incrementing of the leap years by "new_leap = old_leap + 4", and also to be able to use "if year = leap_year, then days in february = 29 and days in year = 366, else days in february = 28 and days in year = 365"
----------
err... used my memory... I was off by one day... argh!
my bad memory: 364 and 365
correct: 365.25 -> 365 and 366 (every 4th year ~ 29 days in february instead of 28)
----------
ya, it's ugly and messy... but unless I'm missing or over-looking something obvious, it should work... lol
----------
I figured that the "%" could be used too, but I was hoping that the "ToInt" and~or "ToDouble", could do the same job... so, can they or not?
---------
all this work on my part....
Jayna wrote:Yes, I wrote some calendar code once...)
old_leap_year = year - (year % 4)
new_leap_year = old_leap_year + 4
I'm depressed... I should quit trying to code... lol (j/k, THANK YOU jayna!, I'm learning bit by bit, lol, of coding and of coding better, from you, hehe)
(I really need to get a better comprehension of the "%"... I understood it... but not how to apply it beyond its definition... it never occured to me to do this: year - year % 4, ARGH!)
I do think my code works... but it sure is the "long ways" of doing your quick and simple:
old_leap_year = year - (year % 4)
new_leap_year = old_leap_year + 4
though my code finds the new_leap_year and then subtracts to get the old_leap_year, the reverse of yours
don't worry about trying to follow my code, as I know how hard it is to follow others' processii of code, math equations, and~or just another person's brain's thoughts-thinking. It took me along time to make sense of what Pertex' was even doing in~with his combat code, it took me awhile just to make sense of his code structure~design so that I could just follow~read it properly, let alone actually understanding how the code worked, hehe.