lancelly commented on code in PR #11429:
URL: https://github.com/apache/iotdb/pull/11429#discussion_r1379835520
##########
iotdb-core/tsfile/src/main/java/org/apache/iotdb/tsfile/utils/TimeDuration.java:
##########
@@ -126,24 +113,29 @@ public static long calcPositiveIntervalByMonth(
TimeUnit currPrecision) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(timeZone);
- long coarserThanMsPart;
for (int i = 0; i < times; i++) {
- coarserThanMsPart = getCoarserThanMsPart(startTime, currPrecision);
- calendar.setTimeInMillis(coarserThanMsPart);
- boolean isLastDayOfMonth =
- calendar.get(Calendar.DAY_OF_MONTH) ==
calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- calendar.add(Calendar.MONTH, duration.monthDuration);
- if (isLastDayOfMonth) {
- calendar.set(Calendar.DAY_OF_MONTH,
calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
- }
- startTime =
- currPrecision.convert(calendar.getTimeInMillis(),
TimeUnit.MILLISECONDS)
- + getFinerThanMsPart(startTime, currPrecision)
- + duration.nonMonthDuration;
+ startTime = getStartTime(startTime, duration, currPrecision, calendar);
}
return startTime;
}
+ private static long getStartTime(
+ long startTime, TimeDuration duration, TimeUnit currPrecision, Calendar
calendar) {
+ long coarserThanMsPart = getCoarserThanMsPart(startTime, currPrecision);
+ calendar.setTimeInMillis(coarserThanMsPart);
+ boolean isLastDayOfMonth =
+ calendar.get(Calendar.DAY_OF_MONTH) ==
calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ calendar.add(Calendar.MONTH, duration.monthDuration);
+ if (isLastDayOfMonth) {
+ calendar.set(Calendar.DAY_OF_MONTH,
calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+ }
+ startTime =
+ currPrecision.convert(calendar.getTimeInMillis(),
TimeUnit.MILLISECONDS)
+ + getFinerThanMsPart(startTime, currPrecision)
+ + duration.nonMonthDuration;
+ return startTime;
Review Comment:
inline startTime
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]