diff options
| author | Paul Eggert | 2019-02-25 11:33:51 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-02-25 11:34:43 -0800 |
| commit | e3bb6f90e999a6d71537806573c48b9ceb3fb413 (patch) | |
| tree | ce802f5d8b071ec7208755f192ef9c7880f5a699 | |
| parent | 0d49078ad80f54b810180a071e2b6b4bcc024851 (diff) | |
| download | emacs-e3bb6f90e999a6d71537806573c48b9ceb3fb413.tar.gz emacs-e3bb6f90e999a6d71537806573c48b9ceb3fb413.zip | |
format-time-string: document new '+' flag
* doc/lispref/os.texi (Time Parsing), etc/NEWS:
* src/timefns.c (Fformat_time_string): Document the new
behavior, added for compatibility with POSIX.1-2017.
| -rw-r--r-- | doc/lispref/os.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | src/timefns.c | 30 |
3 files changed, 30 insertions, 14 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index cb8f25df0a3..59cd5a8fe8a 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -1600,7 +1600,9 @@ This is a synonym for @samp{%m/%d/%y}. | |||
| 1600 | @item %e | 1600 | @item %e |
| 1601 | This stands for the day of month, blank-padded. | 1601 | This stands for the day of month, blank-padded. |
| 1602 | @item %F | 1602 | @item %F |
| 1603 | This stands for the ISO 8601 date format, i.e., @samp{"%Y-%m-%d"}. | 1603 | This stands for the ISO 8601 date format, which is like |
| 1604 | @samp{%+4Y-%m-%d} except that any flags or field width override the | ||
| 1605 | @samp{+} and (after subtracting 6) the @samp{4}. | ||
| 1604 | @item %g | 1606 | @item %g |
| 1605 | This stands for the year corresponding to the ISO week within the century. | 1607 | This stands for the year corresponding to the ISO week within the century. |
| 1606 | @item %G | 1608 | @item %G |
| @@ -1680,7 +1682,9 @@ This stands for a single @samp{%}. | |||
| 1680 | @end table | 1682 | @end table |
| 1681 | 1683 | ||
| 1682 | One or more flag characters can appear immediately after the @samp{%}. | 1684 | One or more flag characters can appear immediately after the @samp{%}. |
| 1683 | @samp{0} pads with zeros, @samp{_} pads with blanks, @samp{-} | 1685 | @samp{0} pads with zeros, @samp{+} pads with zeros and also puts |
| 1686 | @samp{+} before nonnegative year numbers with more than four digits, | ||
| 1687 | @samp{_} pads with blanks, @samp{-} | ||
| 1684 | suppresses padding, @samp{^} upper-cases letters, and @samp{#} | 1688 | suppresses padding, @samp{^} upper-cases letters, and @samp{#} |
| 1685 | reverses the case of letters. | 1689 | reverses the case of letters. |
| 1686 | 1690 | ||
| @@ -1343,6 +1343,12 @@ floating-point operators do. | |||
| 1343 | +++ | 1343 | +++ |
| 1344 | ** New function 'time-equal-p' compares time values for equality. | 1344 | ** New function 'time-equal-p' compares time values for equality. |
| 1345 | 1345 | ||
| 1346 | +++ | ||
| 1347 | ** 'format-time-string' supports a new conversion specifier flag '+' | ||
| 1348 | that acts like the '0' flag but also puts a '+' before nonnegative | ||
| 1349 | years containing more than four digits. This is for compatibility | ||
| 1350 | with POSIX.1-2017. | ||
| 1351 | |||
| 1346 | ** 'define-minor-mode' automatically documents the meaning of ARG. | 1352 | ** 'define-minor-mode' automatically documents the meaning of ARG. |
| 1347 | 1353 | ||
| 1348 | +++ | 1354 | +++ |
diff --git a/src/timefns.c b/src/timefns.c index 7e061228e2c..5beeaf57a25 100644 --- a/src/timefns.c +++ b/src/timefns.c | |||
| @@ -1267,7 +1267,7 @@ by text that describes the specified date and time in TIME: | |||
| 1267 | %c is the locale's date and time format. | 1267 | %c is the locale's date and time format. |
| 1268 | %x is the locale's "preferred" date format. | 1268 | %x is the locale's "preferred" date format. |
| 1269 | %D is like "%m/%d/%y". | 1269 | %D is like "%m/%d/%y". |
| 1270 | %F is the ISO 8601 date format (like "%Y-%m-%d"). | 1270 | %F is the ISO 8601 date format (like "%+4Y-%m-%d"). |
| 1271 | 1271 | ||
| 1272 | %R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p". | 1272 | %R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p". |
| 1273 | %X is the locale's "preferred" time format. | 1273 | %X is the locale's "preferred" time format. |
| @@ -1275,17 +1275,23 @@ by text that describes the specified date and time in TIME: | |||
| 1275 | Finally, %n is a newline, %t is a tab, %% is a literal %, and | 1275 | Finally, %n is a newline, %t is a tab, %% is a literal %, and |
| 1276 | unrecognized %-sequences stand for themselves. | 1276 | unrecognized %-sequences stand for themselves. |
| 1277 | 1277 | ||
| 1278 | Certain flags and modifiers are available with some format controls. | 1278 | A %-sequence can contain optional flags, field width, and a modifier |
| 1279 | The flags are `_', `-', `^' and `#'. For certain characters X, | 1279 | (in that order) after the `%'. The flags are: |
| 1280 | %_X is like %X, but padded with blanks; %-X is like %X, | 1280 | |
| 1281 | but without padding. %^X is like %X, but with all textual | 1281 | `-' Do not pad the field. |
| 1282 | characters up-cased; %#X is like %X, but with letter-case of | 1282 | `_' Pad with spaces. |
| 1283 | all textual characters reversed. | 1283 | `0' Pad with zeros. |
| 1284 | %NX (where N stands for an integer) is like %X, | 1284 | `+' Pad with zeros and put `+' before nonnegative year numbers with >4 digits. |
| 1285 | but takes up at least N (a number) positions. | 1285 | `^' Use upper case characters if possible. |
| 1286 | The modifiers are `E' and `O'. For certain characters X, | 1286 | `#' Use opposite case characters if possible. |
| 1287 | %EX is a locale's alternative version of %X; | 1287 | |
| 1288 | %OX is like %X, but uses the locale's number symbols. | 1288 | A field width N is an unsigned decimal integer with a leading digit nonzero. |
| 1289 | %NX is like %X, but takes up at least N positions. | ||
| 1290 | |||
| 1291 | The modifiers are: | ||
| 1292 | |||
| 1293 | `E' Use the locale's alternative version. | ||
| 1294 | `O' Use the locale's number symbols. | ||
| 1289 | 1295 | ||
| 1290 | For example, to produce full ISO 8601 format, use "%FT%T%z". | 1296 | For example, to produce full ISO 8601 format, use "%FT%T%z". |
| 1291 | 1297 | ||