varmod-gmtime.mk revision 1.3 1 1.3 rillig # $NetBSD: varmod-gmtime.mk,v 1.3 2020/10/29 18:59:43 rillig Exp $
2 1.1 rillig #
3 1.2 rillig # Tests for the :gmtime variable modifier, which formats a timestamp
4 1.2 rillig # using strftime(3).
5 1.1 rillig
6 1.2 rillig all: mod-gmtime
7 1.2 rillig all: mod-gmtime-indirect
8 1.2 rillig
9 1.3 rillig # Test for the default time format, %c. Since the time always varies, it's
10 1.3 rillig # only possible to check for the general format here. The names of the
11 1.3 rillig # month and weekday are always in English, independent from the locale.
12 1.3 rillig # Example: Thu Oct 29 18:56:41 2020
13 1.3 rillig .if ${:U:gmtime:tW:M??? ??? ?? ??\:??\:?? ????} == ""
14 1.3 rillig . error
15 1.3 rillig .endif
16 1.3 rillig
17 1.2 rillig mod-gmtime:
18 1.2 rillig @echo $@:
19 1.2 rillig @echo ${%Y:L:gmtim=1593536400} # modifier name too short
20 1.2 rillig @echo ${%Y:L:gmtime=1593536400} # 2020-07-01T00:00:00Z
21 1.2 rillig @echo ${%Y:L:gmtimer=1593536400} # modifier name too long
22 1.2 rillig @echo ${%Y:L:gm=gm:M*}
23 1.2 rillig
24 1.2 rillig mod-gmtime-indirect:
25 1.2 rillig @echo $@:
26 1.2 rillig
27 1.2 rillig # As of 2020-08-16, it is not possible to pass the seconds via a
28 1.2 rillig # variable expression. This is because parsing of the :gmtime
29 1.2 rillig # modifier stops at the '$' and returns to ApplyModifiers.
30 1.2 rillig #
31 1.2 rillig # There, a colon would be skipped but not a dollar.
32 1.2 rillig # Parsing therefore continues at the '$' of the ${:U159...}, looking
33 1.2 rillig # for an ordinary variable modifier.
34 1.2 rillig #
35 1.2 rillig # At this point, the ${:U} is expanded and interpreted as a variable
36 1.2 rillig # modifier, which results in the error message "Unknown modifier '1'".
37 1.2 rillig #
38 1.2 rillig # If ApplyModifier_Gmtime were to pass its argument through
39 1.2 rillig # ParseModifierPart, this would work.
40 1.2 rillig @echo ${%Y:L:gmtime=${:U1593536400}}
41 1.1 rillig
42 1.1 rillig all:
43 1.1 rillig @:;
44