This means that 1.5 rounds to 2, and -1.5 rounds to -2. Moment.js will accept decimal values and do its best to handle them by rounding to the nearest whole number.Īs of 2.12.0 decimal day and month values use absolute value/round to convert to integers. Moment(' 13:00:00').add(24, 'hours').format('LLL')ĭue to leap years, one year may not equal 365 days: moment('').add(1, 'year').format('LL')īecause of the variability of duration in day math, Moment's API does not officially support adding or subtracting decimal values for days and larger. Date math can cause some interesting scenarios.ĭue to daylight saving time, one day may not equal 24 hours: //date math Months of course vary in number of days, and due to leap year, years vary in length as well. This is because the amount of time in a day, month, or year is variable.įor example, due to daylight saving time transition, a day may be anywhere between 23 and 25 hours long. In Moment.js time math assumes a linear time scale, just incrementing or decrementing the UTC-based timestamp by the amount of the time units provided.ĭate math does not use a linear time scale, but rather increments or decrements the dates on the calendar. There is a logical difference between time math and date math.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |