(
Moment context,
TimeUnit value,
boolean lenient
)
| 3291 | } |
| 3292 | |
| 3293 | @Override |
| 3294 | public Moment withValue( |
| 3295 | Moment context, |
| 3296 | TimeUnit value, |
| 3297 | boolean lenient |
| 3298 | ) { |
| 3299 | |
| 3300 | if (value == null) { |
| 3301 | throw new IllegalArgumentException("Missing precision."); |
| 3302 | } |
| 3303 | |
| 3304 | Moment result; |
| 3305 | |
| 3306 | switch (value) { |
| 3307 | case DAYS: |
| 3308 | long secsD = Math.floorDiv(context.posixTime, 86400) * 86400; |
| 3309 | return Moment.of(secsD, TimeScale.POSIX); |
| 3310 | case HOURS: |
| 3311 | long secsH = Math.floorDiv(context.posixTime, 3600) * 3600; |
| 3312 | return Moment.of(secsH, TimeScale.POSIX); |
| 3313 | case MINUTES: |
| 3314 | long secsM = Math.floorDiv(context.posixTime, 60) * 60; |
| 3315 | return Moment.of(secsM, TimeScale.POSIX); |
| 3316 | case SECONDS: |
| 3317 | result = Moment.of(context.posixTime, 0, TimeScale.POSIX); |
| 3318 | break; |
| 3319 | case MILLISECONDS: |
| 3320 | int f3 = (context.getNanosecond() / MIO) * MIO; |
| 3321 | result = Moment.of(context.posixTime, f3, TimeScale.POSIX); |
| 3322 | break; |
| 3323 | case MICROSECONDS: |
| 3324 | int f6 = (context.getNanosecond() / 1000) * 1000; |
| 3325 | result = Moment.of(context.posixTime, f6, TimeScale.POSIX); |
| 3326 | break; |
| 3327 | case NANOSECONDS: |
| 3328 | return context; |
| 3329 | default: |
| 3330 | throw new UnsupportedOperationException(value.name()); |
| 3331 | } |
| 3332 | |
| 3333 | if (context.isLeapSecond() && LeapSeconds.getInstance().isEnabled()) { |
| 3334 | return result.plus(1, SI.SECONDS); |
| 3335 | } else { |
| 3336 | return result; |
| 3337 | } |
| 3338 | |
| 3339 | } |
| 3340 | |
| 3341 | @Override |
| 3342 | public boolean isValid( |
nothing calls this directly
no test coverage detected