I would like to create an animation, where one frame are represents one day and the date are displayed.
But i have problems with the leap year calculations.
I have two constant input values from two slider: the starting year and the starting day of the year. These values are increment with based on (time/thisComp.frameDuration) - but i can't solve the problem of the different length of february in leap years...
Do you have any idea?
Leap year calculation
By using the date object already program in Expression, it will automatically give you the leap year once you reach a year that has a leap year.
Pick the previous month from the month you want to use.
In computer programming it's common to start counting from 0, so 0 represents January.
Adding 1 is going to give you the first date of the month if you are at frame 0.
If you are at the 0 frame and you don't add 1 it's going to give you the date from the previous month.
2016 was a leap year, and once you reach next by scrolling the time indicator in 2017 February is back at 28 days.
Whole code:
Code: Select all
var d = new Date(2016, 1); // new Date(Year, Month) You can pick any year and month you want to start with.
Pick the previous month from the month you want to use.
In computer programming it's common to start counting from 0, so 0 represents January.
Code: Select all
var timer = time / thisComp.frameDuration;
d.setDate(timer + 1); // setDate() allows you to add to the preexisting date.
If you are at the 0 frame and you don't add 1 it's going to give you the date from the previous month.
Code: Select all
d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate();
Whole code:
Code: Select all
var d = new Date(2016, 1);
var timer = time / thisComp.frameDuration;
d.setDate(timer + 1);
d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate();
For Expression Tutorials:
https://www.youtube.com/c/CodingAfterEffects
https://www.youtube.com/c/CodingAfterEffects
No problem, I'm glad I was able to help out.
For Expression Tutorials:
https://www.youtube.com/c/CodingAfterEffects
https://www.youtube.com/c/CodingAfterEffects