Merge branch '21666-provision-test-improvement'
[arvados.git] / services / api / lib / db_current_time.rb
index ef68b0d09a9d913fa364b07390df7e4f81001743..2d58e3c3894fc0ccf35732fa8d28096672bfdf9c 100644 (file)
@@ -1,7 +1,15 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 module DbCurrentTime
-  CURRENT_TIME_SQL = "SELECT CURRENT_TIMESTAMP"
+  CURRENT_TIME_SQL = "SELECT clock_timestamp() AT TIME ZONE 'UTC'"
 
   def db_current_time
-    Time.parse(ActiveRecord::Base.connection.select_value(CURRENT_TIME_SQL)).to_time
+    ActiveRecord::Base.connection.select_value(CURRENT_TIME_SQL)
+  end
+
+  def db_transaction_time
+    ActiveRecord::Base.connection.select_value("SELECT current_timestamp AT TIME ZONE 'UTC'")
   end
 end