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 )


jquery

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

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

jQuery Simple Textarea Character Counter | jQuery Character Count

Download The File: https://drive.google.com/file/d/1xcBmP2tBXwGThV-FlnClWD08hFKO6cAL/view?usp=sharing Other PlayList: There is a complete playlist of JavaScript

jQuery / Plugin / jQuery Smooth Scroll

jQuery Smooth Scroll jQuery Smooth Scroll은 HTML 내에서 링크를 클릭하여 이동할 때, 부드럽게 이동하도록 만들어주는 플러그인입니다. GitHub : https://github.com/kswedberg/jquery-smooth-scroll Download : https://github.com/kswedberg/jquery-smooth-scroll/archive/master.zip 기본 사용법 다음처럼 문서 내에서 이동하는 링크를 가진 [...]

Dynamically Add/Remove Multiple input Fields and Submit to DB with jQuery and Laravel

In this tutorial, we will sho you how to dynamically add/remove multiple input fields and submit to database with jquery and laravel

Querying DOM in jQuery | jQuery Tutorial for Beginners

This video on Querying DOM in jQuery will help you understand the DOM manipulation methods with hands-on.