MCPcopy Create free account
hub / github.com/csev/py4e / bubble

Function bubble

code/gmane/Chart.bundle.js:4458–4503  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4456 }
4457
4458 function bubble () {
4459 var milliseconds = this._milliseconds;
4460 var days = this._days;
4461 var months = this._months;
4462 var data = this._data;
4463 var seconds, minutes, hours, years, monthsFromDays;
4464
4465 // if we have a mix of positive and negative values, bubble down first
4466 // check: https://github.com/moment/moment/issues/2166
4467 if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
4468 (milliseconds <= 0 && days <= 0 && months <= 0))) {
4469 milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
4470 days = 0;
4471 months = 0;
4472 }
4473
4474 // The following code bubbles up values, see the tests for
4475 // examples of what that means.
4476 data.milliseconds = milliseconds % 1000;
4477
4478 seconds = absFloor(milliseconds / 1000);
4479 data.seconds = seconds % 60;
4480
4481 minutes = absFloor(seconds / 60);
4482 data.minutes = minutes % 60;
4483
4484 hours = absFloor(minutes / 60);
4485 data.hours = hours % 24;
4486
4487 days += absFloor(hours / 24);
4488
4489 // convert days to months
4490 monthsFromDays = absFloor(daysToMonths(days));
4491 months += monthsFromDays;
4492 days -= absCeil(monthsToDays(monthsFromDays));
4493
4494 // 12 months -> 1 year
4495 years = absFloor(months / 12);
4496 months %= 12;
4497
4498 data.days = days;
4499 data.months = months;
4500 data.years = years;
4501
4502 return this;
4503 }
4504
4505 function daysToMonths (days) {
4506 // 400 years have 146097 days (taking into account leap year rules)

Callers

nothing calls this directly

Calls 4

absCeilFunction · 0.85
monthsToDaysFunction · 0.85
absFloorFunction · 0.85
daysToMonthsFunction · 0.85

Tested by

no test coverage detected