]> git.proxmox.com Git - pmg-api.git/commitdiff
PMG/DBTools.pm: new helper get_remote_time
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 11 Apr 2017 05:32:53 +0000 (07:32 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 11 Apr 2017 05:32:53 +0000 (07:32 +0200)
PMG/DBTools.pm

index 7fad87c3f7b0392b2e6f62626f8104722bb572ec..718c14f50756d89bb2a02ed181999892994fc122 100644 (file)
@@ -1037,6 +1037,17 @@ sub init_ruledb {
     cond_create_std_actions ($ruledb);
 }
 
+sub get_remote_time {
+    my ($rdb) = @_;
+
+    my $sth = $rdb->prepare("SELECT EXTRACT (EPOCH FROM TIMESTAMP (0) WITH TIME ZONE 'now') as ctime;");
+    $sth->execute();
+    my $ctinfo = $sth->fetchrow_hashref();
+    $sth->finish ();
+
+    return $ctinfo ? $ctinfo->{ctime} : 0;
+}
+
 sub init_masterdb {
     my ($lcid, $database) = @_;