diff tests/test-command-template.t @ 26128:51f6940d3b4f

templater: add optional timezone argument to localdate() The keyword extension uses "utcdate" for a different function, so we can't add new "utcdate" filter or function. Instead, this patch extends "localdate" to a general timezone converter.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 18 Aug 2015 22:15:46 +0900
parents 7012be5ab5bd
children 662ea52d5dca
line wrap: on
line diff
--- a/tests/test-command-template.t	Tue Sep 01 19:15:16 2015 +0900
+++ b/tests/test-command-template.t	Tue Aug 18 22:15:46 2015 +0900
@@ -3109,6 +3109,25 @@
   hg: parse error: get() expects a dict as first argument
   [255]
 
+Test localdate(date, tz) function:
+
+  $ TZ=JST-09 hg log -r0 -T '{date|localdate|isodate}\n'
+  1970-01-01 09:00 +0900
+  $ TZ=JST-09 hg log -r0 -T '{localdate(date, "UTC")|isodate}\n'
+  1970-01-01 00:00 +0000
+  $ TZ=JST-09 hg log -r0 -T '{localdate(date, "+0200")|isodate}\n'
+  1970-01-01 02:00 +0200
+  $ TZ=JST-09 hg log -r0 -T '{localdate(date, "0")|isodate}\n'
+  1970-01-01 00:00 +0000
+  $ TZ=JST-09 hg log -r0 -T '{localdate(date, 0)|isodate}\n'
+  1970-01-01 00:00 +0000
+  $ hg log -r0 -T '{localdate(date, "invalid")|isodate}\n'
+  hg: parse error: localdate expects a timezone
+  [255]
+  $ hg log -r0 -T '{localdate(date, date)|isodate}\n'
+  hg: parse error: localdate expects a timezone
+  [255]
+
 Test shortest(node) function:
 
   $ echo b > b