Calculating year from total minutes while accounting for leap year

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 )


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

jQuery ajax get request method example

### jQuery Ajax Get Request Method Example This article is originally published at [https://www.tutsmake.com/jquery-api-ajax-get-method-example/](https://www.tutsmake.com/jquery-api-ajax-get-method-example/...

jQuery Crash Course: jQuery Tutorial Step by Step

jQuery Crash Course: jQuery Tutorial Step by Step