From 37dba37084389c7c9c895dfc5ad5092e5b454b21 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be>
Date: Thu, 21 Dec 2017 15:07:53 +0100
Subject: [PATCH] :sparkles: feat(template): Add special epoch format for date
 modifier

Useful for filling shadowExpire with templates, this works by giving
 'epoch' as format in the date modifier.
Result is the number of date since epoch, as is needed in shadowExpire
 field
(Standard format U is number of seconds since epoch, aka timestamp)

issue #5746
---
 include/class_templateHandling.inc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/class_templateHandling.inc b/include/class_templateHandling.inc
index 731aca9e0..54c5f8ec7 100644
--- a/include/class_templateHandling.inc
+++ b/include/class_templateHandling.inc
@@ -364,6 +364,10 @@ class templateHandling
       $args[] = 'd.m.Y';
     }
     $dateObject = new DateTime($args[0], new DateTimeZone('UTC'));
+    if ($args[1] == 'epoch') {
+      /* Special handling for shadowExpire: days since epoch */
+      return array(floor($dateObject->format('U') / 86400));
+    }
     return array($dateObject->format($args[1]));
   }
 
-- 
GitLab