Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/6981#discussion_r34867418
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -378,4 +395,183 @@ object DateTimeUtils {
c.set(segments(0), segments(1) - 1, segments(2), 0, 0, 0)
Some((c.getTimeInMillis / 1000 / 3600 / 24).toInt)
}
+
+ /**
+ * Returns the hour value of a given timestamp value. The timestamp is
expressed in microseconds.
+ */
+ def getHours(timestamp: Long): Int = {
+ val localTs = (timestamp / 1000) + defaultTimeZone.getOffset(timestamp
/ 1000)
+ ((localTs / 1000 / 3600) % 24).toInt
+ }
+
+ /**
+ * Returns the minute value of a given timestamp value. The timestamp is
expressed in
+ * microseconds.
+ */
+ def getMinutes(timestamp: Long): Int = {
+ val localTs = (timestamp / 1000) + defaultTimeZone.getOffset(timestamp
/ 1000)
+ ((localTs / 1000 / 60) % 60).toInt
+ }
+
+ /**
+ * Returns the second value of a given timestamp value. The timestamp is
expressed in
+ * microseconds.
+ */
+ def getSeconds(timestamp: Long): Int = {
+ val localTs = (timestamp / 1000) + defaultTimeZone.getOffset(timestamp
/ 1000)
--- End diff --
I think the offset of timezone should be cut off by minute.
---
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]