# Calculating year from total minutes while accounting for leap year I'm putting together an ICS file generator using jquery. After inputting the Date and time zone I figured it would be easiest to calculate out total minutes then make the timezone conversion to Z-time / UTC-0 / GMT and reconvert the total time into each appropriate time unit (year, month, date, hour and minute).

I'm putting together an ICS file generator using jquery. After inputting the Date and time zone I figured it would be easiest to calculate out total minutes then make the timezone conversion to Z-time / UTC-0 / GMT and reconvert the total time into each appropriate time unit (year, month, date, hour and minute).

My question concerns the logic of my function: is this the most effective way to do this calculation, 2018 checks? Keep in mind, every leap year (current year is divisible by 4) has 527040 minutes and the common year (not divisible by 4) has 525600.

```var timeTot = 1061911800; // for debug
var uyear = 1; // DODGE DIVIDE BY ZERO ERROR

while (timeTot >= 525600 || timeTot >= 527040) {
if (uyear % 4 != 0) { // is common year?
timeTot -= 525600;
uyear++;
} else if (uyear % 4 == 0) { // is leap year?
timeTot -= 527040;
uyear++;
} else {
//infinite loop!
timeTot = 0;
}
}
uyear -= 1; // UNDODGE DIVIDE BY ZERO
// uyear is 2018 ( 1/1/[email protected]:00 UTC-6 )
```

## Hire Dedicated Jquery Developer

Are You Looking To Hire a jQuery Programmer? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")**, a leading jQuery application development company, can help you build interactive front-end solutions to leapfrog the digital...