Returns a {@link java.time.Period} of time between the first day of this year/month (inclusive) and the
given {@link java.time.YearMonth} (exclusive).

@param self  a YearMonth
@param other another YearMonth
@return a Period
@since 2.5.0
421977
public static Period rightShift(YearMonth self, YearMonth other) {
        return Period.between(self.atDay(1), other.atDay(1));
    }
374647
private static long periodEnd(long now, long period, QDate cal)
  {
    if (period < 0)
      return Long.MAX_VALUE;
    else if (period == 0)
      return now;

    if (period < 30 * DAY) {
      cal.setGMTTime(now);

      long localTime = cal.getLocalTime();

      localTime = localTime + (period - (localTime + 4 * DAY) % period);

      cal.setLocalTime(localTime);

      return cal.getGMTTime();
    }

    if (period % (30 * DAY) == 0) {
      int months = (int) (period / (30 * DAY));

      cal.setGMTTime(now);
      long year = cal.getYear();
      int month = cal.getMonth();

      cal.setLocalTime(0);
      
      cal.setDate(year, month + months, 1);

      return cal.getGMTTime();
    }

    if (period % (365 * DAY) == 0) {
      long years = (period / (365 * DAY));

      cal.setGMTTime(now);
      long year = cal.getYear();

      cal.setLocalTime(0);

      long newYear = year + (years - year % years);
      
      cal.setDate(newYear, 0, 1);

      return cal.getGMTTime();
    }

    cal.setGMTTime(now);

    long localTime = cal.getLocalTime();

    localTime = localTime + (period - (localTime + 4 * DAY) % period);

    cal.setLocalTime(localTime);

    return cal.getGMTTime();
  }
1366874
function startOfMonth() {
      var result = this.clone();
      result.day = 1;
      result.isDate = true;
      result.hour = 0;
      result.minute = 0;
      result.second = 0;
      return result;
    }
1036669
public int getIntervalDays( HexaDate other )
	{
		long interval = other.getJavaDate().getTime() - getJavaDate().getTime();
		int res = (int) (interval / 86400000);
		return res;
	}
901858
public static boolean isSameMonth(final Date date1, final Date date2) {
        final Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date1);

        final Calendar cal2 = Calendar.getInstance();
        cal2.setTime(date2);

        return cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
    }
1258374
public static OffsetDateTime toOffsetDateTime(final Calendar self) {
        return OffsetDateTime.of(toLocalDateTime(self), getZoneOffset(self));
    }
683731
private static int getMonthDays(int month, int year) {
        Integer[] newMonths = getAdjustedMonthDays(year);
        return newMonths[month].intValue();
    }
663192
public static Months between(CalendarMonth m1, CalendarMonth m2) {

        PlainDate d1 = m1.atDayOfMonth(1);
        PlainDate d2 = m2.atDayOfMonth(1);
        return Months.between(d1, d2);

    }
438236
public static CalendarMonth from(YearMonth yearMonth) {

        return CalendarMonth.of(yearMonth.getYear(), yearMonth.getMonthValue());

    }
661730
public static Calendar toCalendar(final Instant self) {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.setTime(toDate(self));
        return cal;
    }
968179
public static Date addMonth(Date date1, int addMonth) {
        Date resultDate = null;
        Calendar c = Calendar.getInstance();
        c.setTime(date1); // 设置当前日期
        c.add(Calendar.MONTH, addMonth); // 日期加1
        resultDate = c.getTime(); // 结果
        return resultDate;
    }
231461
public static Month plus(final Month self, int months) {
        int monthsPerYear = Month.values().length;
        int val = ((self.getValue() + months - 1) % monthsPerYear) + 1;
        return Month.of(val > 0 ? val : monthsPerYear + val);
    }
1311936
private void getMonthlyRelativeDates(Calendar calendar, int frequency, List<Date> dates)
   {
      long startDate = calendar.getTimeInMillis();
      calendar.set(Calendar.DAY_OF_MONTH, 1);
      int dayNumber = NumberHelper.getInt(m_dayNumber);

      while (moreDates(calendar, dates))
      {
         if (dayNumber > 4)
         {
            setCalendarToLastRelativeDay(calendar);
         }
         else
         {
            setCalendarToOrdinalRelativeDay(calendar, dayNumber);
         }

         if (calendar.getTimeInMillis() > startDate)
         {
            dates.add(calendar.getTime());
            if (!moreDates(calendar, dates))
            {
               break;
            }
         }
         calendar.set(Calendar.DAY_OF_MONTH, 1);
         calendar.add(Calendar.MONTH, frequency);
      }
   }
187353
static int getMonthLength(int month, int year) {
      Integer[] newMonths = getAdjustedMonthLength(year);
      return newMonths[month].intValue();
    }
120758
private static int getDayOfMonth(int dayOfYear, int month, int year) {

        Integer[] newMonths = getAdjustedMonthDays(year);

        if (dayOfYear >= 0) {
            if (month > 0) {
                return dayOfYear - newMonths[month].intValue();
            } else {
                return dayOfYear;
            }
        } else {
            dayOfYear = (isLeapYear(year) ? (dayOfYear + 355)
                    : (dayOfYear + 354));
            if (month > 0) {
                return dayOfYear - newMonths[month].intValue();
            } else {
                return dayOfYear;
            }
        }
    }
762525
public static long periodEnd(long now, long period)
  {
    QDate localCalendar = QDate.allocateLocalDate();
    
    long endTime = periodEnd(now, period, localCalendar);
    
    QDate.freeLocalDate(localCalendar);
    
    return endTime;
  }
1018911
public NumberExpression<Integer> dayOfMonth() {
        if (dayOfMonth == null) {
            dayOfMonth = Expressions.numberOperation(Integer.class, Ops.DateTimeOps.DAY_OF_MONTH, mixin);
        }
        return dayOfMonth;
    }