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 ERRORwhile (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 )

### 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