Github user adrian-wang commented on a diff in the pull request:
https://github.com/apache/spark/pull/7589#discussion_r35724424
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -573,4 +573,109 @@ object DateTimeUtils {
dayInYear - 334
}
}
+
+ /**
+ * Returns the date value for the first day of the given month.
+ * The month is expressed in months since 1.1.1970, starting from 0.
+ */
+ def getDaysFromMonths(months: Int): Int = {
+ val yearSinceEpoch = if (months < 0) months / 12 - 1 else months / 12
+ val monthInYearFromZero = months - yearSinceEpoch * 12
+ val daysFromYears = getDaysFromYears(yearSinceEpoch)
+ val febDays = if (isLeapYear(1970 + yearSinceEpoch)) 29 else 28
+ val daysForMonths = Seq(31, febDays, 31, 30, 31, 30, 31, 31, 30, 31,
30, 31)
--- End diff --
when you are updating this pr, you could reuse
`private[this] val daysInNormalYear` in this object.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]