| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: varmod-gmtime.mk,v 1.4 2020/10/31 19:48:23 rillig Exp $ | | 1 | # $NetBSD: varmod-gmtime.mk,v 1.5 2020/10/31 19:55:26 rillig Exp $ |
2 | # | | 2 | # |
3 | # Tests for the :gmtime variable modifier, which formats a timestamp | | 3 | # Tests for the :gmtime variable modifier, which formats a timestamp |
4 | # using strftime(3). | | 4 | # using strftime(3). |
5 | | | 5 | |
6 | all: mod-gmtime | | 6 | all: mod-gmtime |
7 | all: mod-gmtime-indirect | | 7 | all: mod-gmtime-indirect |
8 | all: parse-errors | | 8 | all: parse-errors |
9 | | | 9 | |
10 | # Test for the default time format, %c. Since the time always varies, it's | | 10 | # Test for the default time format, %c. Since the time always varies, it's |
11 | # only possible to check for the general format here. The names of the | | 11 | # only possible to check for the general format here. The names of the |
12 | # month and weekday are always in English, independent from the locale. | | 12 | # month and weekday are always in English, independent from the locale. |
13 | # Example: Thu Oct 29 18:56:41 2020 | | 13 | # Example: Thu Oct 29 18:56:41 2020 |
14 | .if ${:U:gmtime:tW:M??? ??? ?? ??\:??\:?? ????} == "" | | 14 | .if ${:U:gmtime:tW:M??? ??? ?? ??\:??\:?? ????} == "" |
| @@ -39,26 +39,30 @@ mod-gmtime-indirect: | | | @@ -39,26 +39,30 @@ mod-gmtime-indirect: |
39 | # If ApplyModifier_Gmtime were to pass its argument through | | 39 | # If ApplyModifier_Gmtime were to pass its argument through |
40 | # ParseModifierPart, this would work. | | 40 | # ParseModifierPart, this would work. |
41 | @echo ${%Y:L:gmtime=${:U1593536400}} | | 41 | @echo ${%Y:L:gmtime=${:U1593536400}} |
42 | | | 42 | |
43 | parse-errors: | | 43 | parse-errors: |
44 | @echo $@: | | 44 | @echo $@: |
45 | | | 45 | |
46 | # As of 2020-10-31, it is possible to pass negative time stamps | | 46 | # As of 2020-10-31, it is possible to pass negative time stamps |
47 | # to the :gmtime modifier, resulting in dates before 1970. | | 47 | # to the :gmtime modifier, resulting in dates before 1970. |
48 | # Going back 50 years in the past is not a practical use case for | | 48 | # Going back 50 years in the past is not a practical use case for |
49 | # make. | | 49 | # make. |
50 | : -1 becomes ${:L:gmtime=-1}. | | 50 | : -1 becomes ${:L:gmtime=-1}. |
51 | | | 51 | |
| | | 52 | # Spaces are allowed, not because it would make sense but just as |
| | | 53 | # a side-effect from using strtoul. |
| | | 54 | : space 1 becomes ${:L:gmtime= 1}. |
| | | 55 | |
52 | # 0 means now; to get consistent test results, the actual value has | | 56 | # 0 means now; to get consistent test results, the actual value has |
53 | # to be normalized. | | 57 | # to be normalized. |
54 | : 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}. | | 58 | : 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}. |
55 | | | 59 | |
56 | : 1 becomes ${:L:gmtime=1}. | | 60 | : 1 becomes ${:L:gmtime=1}. |
57 | | | 61 | |
58 | : INT32_MAX becomes ${:L:gmtime=2147483647}. | | 62 | : INT32_MAX becomes ${:L:gmtime=2147483647}. |
59 | | | 63 | |
60 | # This may be different if time_t is still a 32-bit signed integer. | | 64 | # This may be different if time_t is still a 32-bit signed integer. |
61 | : INT32_MAX + 1 becomes ${:L:gmtime=2147483648}. | | 65 | : INT32_MAX + 1 becomes ${:L:gmtime=2147483648}. |
62 | | | 66 | |
63 | # Integer overflow. | | 67 | # Integer overflow. |
64 | # Because this modifier is implemented using strtoul, the parsed | | 68 | # Because this modifier is implemented using strtoul, the parsed |