1 1.2 rillig # $NetBSD: varmod-gmtime.mk,v 1.2 2020/08/16 12:48:55 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.2 rillig mod-gmtime: 10 1.2 rillig @echo $@: 11 1.2 rillig @echo ${%Y:L:gmtim=1593536400} # modifier name too short 12 1.2 rillig @echo ${%Y:L:gmtime=1593536400} # 2020-07-01T00:00:00Z 13 1.2 rillig @echo ${%Y:L:gmtimer=1593536400} # modifier name too long 14 1.2 rillig @echo ${%Y:L:gm=gm:M*} 15 1.2 rillig 16 1.2 rillig mod-gmtime-indirect: 17 1.2 rillig @echo $@: 18 1.2 rillig 19 1.2 rillig # As of 2020-08-16, it is not possible to pass the seconds via a 20 1.2 rillig # variable expression. This is because parsing of the :gmtime 21 1.2 rillig # modifier stops at the '$' and returns to ApplyModifiers. 22 1.2 rillig # 23 1.2 rillig # There, a colon would be skipped but not a dollar. 24 1.2 rillig # Parsing therefore continues at the '$' of the ${:U159...}, looking 25 1.2 rillig # for an ordinary variable modifier. 26 1.2 rillig # 27 1.2 rillig # At this point, the ${:U} is expanded and interpreted as a variable 28 1.2 rillig # modifier, which results in the error message "Unknown modifier '1'". 29 1.2 rillig # 30 1.2 rillig # If ApplyModifier_Gmtime were to pass its argument through 31 1.2 rillig # ParseModifierPart, this would work. 32 1.2 rillig @echo ${%Y:L:gmtime=${:U1593536400}} 33 1.1 rillig 34 1.1 rillig all: 35 1.1 rillig @:; 36