Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate leap year in jalali calendar?

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?

like image 882
Aron Glover Avatar asked Mar 25 '20 10:03

Aron Glover


People also ask

How do you calculate a leap year calendar?

Any year that is evenly divisible by 4 is a leap year: for example, 1988, 1992, and 1996 are leap years.

What is the easiest way to calculate leap year?

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.

How is leap month calculated?

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.

How do I calculate a leap year in Excel?

=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.


1 Answers

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;
}
like image 136
sina rahmani Avatar answered Oct 09 '22 04:10

sina rahmani