As you know, there is a leap every four years in the Jalali calendar (There are, of course, a few exceptions)
And instead of having 365 days a year, it has 366 days :)
And the other problem is that some months are 29 days and some months are 30 days and some months 31 :|
I use moment library for generating these dates ( of course using fa method)
This website which called تقویم is doing it very well.
var moment = require('moment-jalaali')
moment().format('jYYYY/jM/jD')
Now my question is how to identify which months are 29 and 30 and 31 and which year is leap?
Any year that is evenly divisible by 4 is a leap year: for example, 1988, 1992, and 1996 are leap years.
So 2000 and 2400 are leap years but 1800, 1900, 2100, 2200 and 2300 are not. Apart from that, every year divisible by 4 (2012, 2016, 2020, 2024, etc.) is a leap year. Example: look just before 2100, the worst year is 1.2 days ahead, but because 2100 is not a leap year they all get adjusted back by 1 day.
To determine when, find the number of new moons between the 11th month in one year and the 11th month in the following year. A leap month is inserted if there are 13 New Moons from the start of the 11th month in the first year to the start of the 11th month in the next year.
=MONTH(DATE(YEAR(A2),2,29))=2 Year is a Leap Year in Excel. After Excel has returned the initial result, copy the formula into the cells down the column for the next results to be returned.
In my previous project I had the same problem, You must use this method to do this
This function isn't in javascript But this algorithm work very good for your leap year
internal static bool IsLeapYear(int y)
{
int[] matches = { 1, 5, 9, 13, 17, 22, 26, 30 };
int modulus = y - ((y / 33) * 33);
bool K = false;
for (int n = 0; n != 8; n++) if (matches[n] == modulus) K = true;
return K;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With