diff options
| author | Paul Eggert | 2011-01-31 23:23:48 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-01-31 23:23:48 -0800 |
| commit | a4180391acf904dde6ec72bd37b8f908f69ac3e8 (patch) | |
| tree | 414be2d27e23b8ec836d6eac9b0a7d96f2c5671d | |
| parent | abb97fbbedcd84a13bae7b7b70251514bf97cdbb (diff) | |
| download | emacs-a4180391acf904dde6ec72bd37b8f908f69ac3e8.tar.gz emacs-a4180391acf904dde6ec72bd37b8f908f69ac3e8.zip | |
format-time-string now supports subsecond time stamp resolution
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 8 | ||||
| -rw-r--r-- | etc/ChangeLog | 5 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/editfns.c | 25 |
6 files changed, 47 insertions, 10 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 063ea78c09a..a3a89219bff 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-02-01 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | format-time-string now supports subsecond time stamp resolution | ||
| 4 | * os.texi (Time Parsing): Document %N. | ||
| 5 | |||
| 1 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> | 6 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * vol1.texi (Top): | 8 | * vol1.texi (Top): |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 576f847d98e..b226d676462 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -21,7 +21,7 @@ terminal and the screen. | |||
| 21 | * System Environment:: Distinguish the name and kind of system. | 21 | * System Environment:: Distinguish the name and kind of system. |
| 22 | * User Identification:: Finding the name and user id of the user. | 22 | * User Identification:: Finding the name and user id of the user. |
| 23 | * Time of Day:: Getting the current time. | 23 | * Time of Day:: Getting the current time. |
| 24 | * Time Conversion:: Converting a time from numeric form to | 24 | * Time Conversion:: Converting a time from numeric form to |
| 25 | calendrical data and vice versa. | 25 | calendrical data and vice versa. |
| 26 | * Time Parsing:: Converting a time from numeric form to text | 26 | * Time Parsing:: Converting a time from numeric form to text |
| 27 | and vice versa. | 27 | and vice versa. |
| @@ -1336,6 +1336,12 @@ This stands for the month (01-12). | |||
| 1336 | This stands for the minute (00-59). | 1336 | This stands for the minute (00-59). |
| 1337 | @item %n | 1337 | @item %n |
| 1338 | This stands for a newline. | 1338 | This stands for a newline. |
| 1339 | @item %N | ||
| 1340 | This stands for the nanoseconds (000000000-999999999). To ask for | ||
| 1341 | fewer digits, use @samp{%3N} for milliseconds, @samp{%6N} for | ||
| 1342 | microseconds, etc. Any excess digits are discarded, without rounding. | ||
| 1343 | Currently Emacs time stamps are at best microsecond resolution so the | ||
| 1344 | last three digits generated by plain @samp{%N} are always zero. | ||
| 1339 | @item %p | 1345 | @item %p |
| 1340 | This stands for @samp{AM} or @samp{PM}, as appropriate. | 1346 | This stands for @samp{AM} or @samp{PM}, as appropriate. |
| 1341 | @item %r | 1347 | @item %r |
diff --git a/etc/ChangeLog b/etc/ChangeLog index db1c5d41c34..45dfb211bb0 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2011-02-01 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | format-time-string now supports subsecond time stamp resolution | ||
| 4 | * NEWS: Document this. | ||
| 5 | |||
| 1 | 2011-01-28 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2011-01-28 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | Redo spelling of Makefile variables to conform to POSIX. | 8 | Redo spelling of Makefile variables to conform to POSIX. |
| @@ -169,6 +169,10 @@ get and set the SELinux context of a file. | |||
| 169 | *** Tramp offers handlers for file-selinux-context and set-file-selinux-context | 169 | *** Tramp offers handlers for file-selinux-context and set-file-selinux-context |
| 170 | for remote machines which support SELinux. | 170 | for remote machines which support SELinux. |
| 171 | 171 | ||
| 172 | +++ | ||
| 173 | ** The function format-time-string now supports the %N directive, for | ||
| 174 | higher-resolution time stamps. | ||
| 175 | |||
| 172 | ** The function kill-emacs is now run upon receipt of the signals SIGTERM | 176 | ** The function kill-emacs is now run upon receipt of the signals SIGTERM |
| 173 | and SIGHUP, and upon SIGINT in batch mode. | 177 | and SIGHUP, and upon SIGINT in batch mode. |
| 174 | 178 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index 2353116c8bd..c0c09875121 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2011-02-01 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | format-time-string now supports subsecond time stamp resolution | ||
| 4 | * editfns.c (emacs_nmemftime): Renamed from emacs_memftimeu, | ||
| 5 | for consistency with its new argument and with gnulib nstrftime. | ||
| 6 | All callers changed. New argument NS. | ||
| 7 | (Fformat_time_string): Check that the time argument's microseconds | ||
| 8 | component, if any, is in range; this avoids integer overflow and | ||
| 9 | also nstrftime needs this. Document %N. | ||
| 10 | |||
| 1 | 2011-01-31 Andreas Schwab <schwab@linux-m68k.org> | 11 | 2011-01-31 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 12 | ||
| 3 | * image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead | 13 | * image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead |
diff --git a/src/editfns.c b/src/editfns.c index 7364a5bcf15..1733580ee32 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -92,8 +92,8 @@ static void find_field (Lisp_Object, Lisp_Object, Lisp_Object, | |||
| 92 | EMACS_INT *, Lisp_Object, EMACS_INT *); | 92 | EMACS_INT *, Lisp_Object, EMACS_INT *); |
| 93 | static void update_buffer_properties (EMACS_INT, EMACS_INT); | 93 | static void update_buffer_properties (EMACS_INT, EMACS_INT); |
| 94 | static Lisp_Object region_limit (int); | 94 | static Lisp_Object region_limit (int); |
| 95 | static size_t emacs_memftimeu (char *, size_t, const char *, | 95 | static size_t emacs_nmemftime (char *, size_t, const char *, |
| 96 | size_t, const struct tm *, int); | 96 | size_t, const struct tm *, int, int); |
| 97 | static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), | 97 | static void general_insert_function (void (*) (const unsigned char *, EMACS_INT), |
| 98 | void (*) (Lisp_Object, EMACS_INT, | 98 | void (*) (Lisp_Object, EMACS_INT, |
| 99 | EMACS_INT, EMACS_INT, | 99 | EMACS_INT, EMACS_INT, |
| @@ -1549,6 +1549,7 @@ or (if you need time as a string) `format-time-string'. */) | |||
| 1549 | /* Write information into buffer S of size MAXSIZE, according to the | 1549 | /* Write information into buffer S of size MAXSIZE, according to the |
| 1550 | FORMAT of length FORMAT_LEN, using time information taken from *TP. | 1550 | FORMAT of length FORMAT_LEN, using time information taken from *TP. |
| 1551 | Default to Universal Time if UT is nonzero, local time otherwise. | 1551 | Default to Universal Time if UT is nonzero, local time otherwise. |
| 1552 | Use NS as the number of nanoseconds in the %N directive. | ||
| 1552 | Return the number of bytes written, not including the terminating | 1553 | Return the number of bytes written, not including the terminating |
| 1553 | '\0'. If S is NULL, nothing will be written anywhere; so to | 1554 | '\0'. If S is NULL, nothing will be written anywhere; so to |
| 1554 | determine how many bytes would be written, use NULL for S and | 1555 | determine how many bytes would be written, use NULL for S and |
| @@ -1557,7 +1558,8 @@ or (if you need time as a string) `format-time-string'. */) | |||
| 1557 | This function behaves like nstrftime, except it allows null | 1558 | This function behaves like nstrftime, except it allows null |
| 1558 | bytes in FORMAT and it does not support nanoseconds. */ | 1559 | bytes in FORMAT and it does not support nanoseconds. */ |
| 1559 | static size_t | 1560 | static size_t |
| 1560 | emacs_memftimeu (char *s, size_t maxsize, const char *format, size_t format_len, const struct tm *tp, int ut) | 1561 | emacs_nmemftime (char *s, size_t maxsize, const char *format, |
| 1562 | size_t format_len, const struct tm *tp, int ut, int ns) | ||
| 1561 | { | 1563 | { |
| 1562 | size_t total = 0; | 1564 | size_t total = 0; |
| 1563 | 1565 | ||
| @@ -1574,7 +1576,7 @@ emacs_memftimeu (char *s, size_t maxsize, const char *format, size_t format_len, | |||
| 1574 | if (s) | 1576 | if (s) |
| 1575 | s[0] = '\1'; | 1577 | s[0] = '\1'; |
| 1576 | 1578 | ||
| 1577 | result = nstrftime (s, maxsize, format, tp, ut, 0); | 1579 | result = nstrftime (s, maxsize, format, tp, ut, ns); |
| 1578 | 1580 | ||
| 1579 | if (s) | 1581 | if (s) |
| 1580 | { | 1582 | { |
| @@ -1620,6 +1622,7 @@ by text that describes the specified date and time in TIME: | |||
| 1620 | %p is the locale's equivalent of either AM or PM. | 1622 | %p is the locale's equivalent of either AM or PM. |
| 1621 | %M is the minute. | 1623 | %M is the minute. |
| 1622 | %S is the second. | 1624 | %S is the second. |
| 1625 | %N is the nanosecond, %6N the microsecond, %3N the millisecond, etc. | ||
| 1623 | %Z is the time zone name, %z is the numeric form. | 1626 | %Z is the time zone name, %z is the numeric form. |
| 1624 | %s is the number of seconds since 1970-01-01 00:00:00 +0000. | 1627 | %s is the number of seconds since 1970-01-01 00:00:00 +0000. |
| 1625 | 1628 | ||
| @@ -1649,13 +1652,17 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1649 | { | 1652 | { |
| 1650 | time_t value; | 1653 | time_t value; |
| 1651 | int size; | 1654 | int size; |
| 1655 | int usec; | ||
| 1656 | int ns; | ||
| 1652 | struct tm *tm; | 1657 | struct tm *tm; |
| 1653 | int ut = ! NILP (universal); | 1658 | int ut = ! NILP (universal); |
| 1654 | 1659 | ||
| 1655 | CHECK_STRING (format_string); | 1660 | CHECK_STRING (format_string); |
| 1656 | 1661 | ||
| 1657 | if (! lisp_time_argument (time, &value, NULL)) | 1662 | if (! (lisp_time_argument (time, &value, &usec) |
| 1663 | && 0 <= usec && usec < 1000000)) | ||
| 1658 | error ("Invalid time specification"); | 1664 | error ("Invalid time specification"); |
| 1665 | ns = usec * 1000; | ||
| 1659 | 1666 | ||
| 1660 | format_string = code_convert_string_norecord (format_string, | 1667 | format_string = code_convert_string_norecord (format_string, |
| 1661 | Vlocale_coding_system, 1); | 1668 | Vlocale_coding_system, 1); |
| @@ -1678,9 +1685,9 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1678 | 1685 | ||
| 1679 | buf[0] = '\1'; | 1686 | buf[0] = '\1'; |
| 1680 | BLOCK_INPUT; | 1687 | BLOCK_INPUT; |
| 1681 | result = emacs_memftimeu (buf, size, SSDATA (format_string), | 1688 | result = emacs_nmemftime (buf, size, SSDATA (format_string), |
| 1682 | SBYTES (format_string), | 1689 | SBYTES (format_string), |
| 1683 | tm, ut); | 1690 | tm, ut, ns); |
| 1684 | UNBLOCK_INPUT; | 1691 | UNBLOCK_INPUT; |
| 1685 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) | 1692 | if ((result > 0 && result < size) || (result == 0 && buf[0] == '\0')) |
| 1686 | return code_convert_string_norecord (make_unibyte_string (buf, result), | 1693 | return code_convert_string_norecord (make_unibyte_string (buf, result), |
| @@ -1688,10 +1695,10 @@ For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z". */) | |||
| 1688 | 1695 | ||
| 1689 | /* If buffer was too small, make it bigger and try again. */ | 1696 | /* If buffer was too small, make it bigger and try again. */ |
| 1690 | BLOCK_INPUT; | 1697 | BLOCK_INPUT; |
| 1691 | result = emacs_memftimeu (NULL, (size_t) -1, | 1698 | result = emacs_nmemftime (NULL, (size_t) -1, |
| 1692 | SSDATA (format_string), | 1699 | SSDATA (format_string), |
| 1693 | SBYTES (format_string), | 1700 | SBYTES (format_string), |
| 1694 | tm, ut); | 1701 | tm, ut, ns); |
| 1695 | UNBLOCK_INPUT; | 1702 | UNBLOCK_INPUT; |
| 1696 | size = result + 1; | 1703 | size = result + 1; |
| 1697 | } | 1704 | } |