Add `machine` output type to `{time}`
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 25 May 2023 09:22:45 +0000 (11:22 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 25 May 2023 09:22:45 +0000 (11:22 +0200)
This will output a machine-readable version of the datetime, i.e. the ISO-8601
format.

This is intended as a replacement for `{$foo|date:'c'}`.

wcfsetup/install/files/lib/system/template/plugin/TimeFunctionTemplatePlugin.class.php

index 85fc14e016103ef865c7afbdca60426534de4168..6c411ada5dc9c14887b1f6b89a059c7c59b2d492 100644 (file)
@@ -16,6 +16,7 @@ use wcf\system\WCF;
  *  {time time=$timestamp}
  *  {time time=$timestamp type='plainTime'}
  *  {time time=$timestamp type='plainDate'}
+ *  {time time=$timestamp type='machine'}
  *  {time time=$timestamp type='custom' format='Y-m-d'}
  *
  * @author Tim Duesterhus, Marcel Werk
@@ -82,6 +83,8 @@ final class TimeFunctionTemplatePlugin implements IFunctionTemplatePlugin
                     ],
                     $locale
                 );
+            case 'machine':
+                return $dateTime->format(\DateTimeInterface::ATOM);
             case 'custom':
                 return $dateTime->format($tagArgs['format']);
             default: