(
long[] values,
Duration<?> duration,
TimeSource<?> refClock,
boolean weekToDays
)
| 1751 | } |
| 1752 | |
| 1753 | private static void pushDuration( |
| 1754 | long[] values, |
| 1755 | Duration<?> duration, |
| 1756 | TimeSource<?> refClock, |
| 1757 | boolean weekToDays |
| 1758 | ) { |
| 1759 | int len = duration.getTotalLength().size(); |
| 1760 | |
| 1761 | for (int i = 0; i < len; i++) { |
| 1762 | TimeSpan.Item<? extends IsoUnit> item = |
| 1763 | duration.getTotalLength().get(i); |
| 1764 | IsoUnit unit = item.getUnit(); |
| 1765 | long amount = item.getAmount(); |
| 1766 | |
| 1767 | if (unit instanceof CalendarUnit) { |
| 1768 | push(values, CalendarUnit.class.cast(unit), amount, weekToDays); |
| 1769 | } else if (unit instanceof ClockUnit) { |
| 1770 | push(values, ClockUnit.class.cast(unit), amount); |
| 1771 | } else if (unit instanceof OverflowUnit) { |
| 1772 | push( |
| 1773 | values, |
| 1774 | OverflowUnit.class.cast(unit).getCalendarUnit(), |
| 1775 | amount, |
| 1776 | weekToDays); |
| 1777 | } else if (unit.equals(CalendarUnit.weekBasedYears())) { |
| 1778 | values[0] = MathUtils.safeAdd(amount, values[0]); // YEARS |
| 1779 | } else { // approximated duration by normalization without nanos |
| 1780 | Moment unix = Moment.from(refClock.currentTime()); |
| 1781 | PlainTimestamp start = unix.toZonalTimestamp(ZonalOffset.UTC); |
| 1782 | PlainTimestamp end = start.plus(amount, unit); |
| 1783 | IsoUnit[] units = (weekToDays ? TSP_UNITS : STD_UNITS); |
| 1784 | Duration<?> part = Duration.in(units).between(start, end); |
| 1785 | pushDuration(values, part, refClock, weekToDays); |
| 1786 | } |
| 1787 | } |
| 1788 | } |
| 1789 | |
| 1790 | private static void push( |
| 1791 | long[] values, |
no test coverage detected