Top Level Namespace
Defined Under Namespace
Modules: BlackStack
Instance Method Summary collapse
-
#now ⇒ Object
TODO: Move new() to a gem with the CRDB module.
Instance Method Details
#now ⇒ Object
TODO: Move new() to a gem with the CRDB module
return current datetime with format ‘%Y-%m-%d %H:%M:%S %Z`, using the timezone of the database (`select current_setting(’TIMEZONE’)‘) TODO: I am hardcoding the value of `tz` because for any reason `SELECT current_setting(’TIMEZONE’)‘ returns `UTC` instead of `America/Argentina/Buenos_Aires` when I run it from Ruby. Be sure your database is ALWAYS configured with the correct timezone.
28 29 30 31 |
# File 'lib/workmesh.rb', line 28 def now() tz = 'America/Argentina/Buenos_Aires' #DB["SELECT current_setting('TIMEZONE') AS tz"].first[:tz] DB["SELECT current_timestamp() at TIME ZONE '#{tz}' AS now"].first[:now] end |