Github user rxin commented on a diff in the pull request: https://github.com/apache/spark/pull/6986#discussion_r35581446 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala --- @@ -573,4 +573,48 @@ object DateTimeUtils { dayInYear - 334 } } + + /** + * Returns Day of week from String. Starting from friday, marked as 0. + */ + def getDayOfWeekFromString(string: UTF8String): Int = { + val dowString = string.toString.toUpperCase + dowString match { + case "SU" | "SUN" | "SUNDAY" => 2 + case "MO" | "MON" | "MONDAY" => 3 + case "TU" | "TUE" | "TUESDAY" => 4 + case "WE" | "WED" | "WEDNESDAY" => 5 + case "TH" | "THU" | "THURSDAY" => 6 + case "FR" | "FRI" | "FRIDAY" => 0 + case "SA" | "SAT" | "SATURDAY" => 1 + case _ => -1 + } + } + + /** + * Returns the first date which is later than startDate and is of the given dayOfWeek. + */ + def getNextDateForDayOfWeek(startDate: Int, dayOfWeek: Int): Int = { + startDate + 1 + ((dayOfWeek - startDate % 7) % 7 + 7) % 7 + } + + /** + * number of days in a non-leap year. + */ + val days = Seq(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) --- End diff -- make this a private[this] array, rather than a public Seq.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org