Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102021074
D32799.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D32799.diff
View Options
Index: lib/libc/stdtime/strftime.3
===================================================================
--- lib/libc/stdtime/strftime.3
+++ lib/libc/stdtime/strftime.3
@@ -32,7 +32,7 @@
.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 25, 2012
+.Dd November 2, 2021
.Dt STRFTIME 3
.Os
.Sh NAME
@@ -154,6 +154,8 @@
is replaced by the minute as a decimal number (00-59).
.It Cm %m
is replaced by the month as a decimal number (01-12).
+.It Cm %N
+is replaced by the nanosecond as a decimal number (000000000-999999999).
.It Cm %n
is replaced by a newline.
.It Cm %O*
@@ -257,6 +259,7 @@
.Ql %h ,
.Ql %k ,
.Ql %l ,
+.Ql %N ,
.Ql %n ,
.Ql %O* ,
.Ql \&%R ,
Index: lib/libc/stdtime/strftime.c
===================================================================
--- lib/libc/stdtime/strftime.c
+++ lib/libc/stdtime/strftime.c
@@ -41,6 +41,7 @@
#include "tzfile.h"
#include <fcntl.h>
+#include <time.h>
#include <sys/stat.h>
#include "un-namespace.h"
#include "timelocal.h"
@@ -83,7 +84,9 @@
#define PAD_FMT_DAYOFYEAR 2
{ "%03d", "%d", "%3d", "%03d" },
#define PAD_FMT_YEAR 3
- { "%04d", "%d", "%4d", "%04d" }
+ { "%04d", "%d", "%4d", "%04d" },
+#define PAD_FMT_NANOSECONDS 4
+ { "%09d", "%d", "%9d", "%09d" }
};
size_t
@@ -130,6 +133,7 @@
_fmt(const char *format, const struct tm * const t, char *pt,
const char * const ptlim, int *warnp, locale_t loc)
{
+ struct timespec tspec;
int Ealternative, Oalternative, PadIndex;
struct lc_time_T *tptr = __get_current_time_locale(loc);
@@ -290,6 +294,12 @@
fmt_padding[PAD_FMT_MONTH][PadIndex],
pt, ptlim, loc);
continue;
+ case 'N':
+ clock_gettime(CLOCK_REALTIME_FAST, &tspec);
+ pt = _conv(tspec.tv_nsec,
+ fmt_padding[PAD_FMT_NANOSECONDS][PadIndex],
+ pt, ptlim, loc);
+ continue;
case 'n':
pt = _add("\n", pt, ptlim);
continue;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 7, 3:37 PM (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14515893
Default Alt Text
D32799.diff (1 KB)
Attached To
Mode
D32799: strftime: Add support for %N (nanoseconds)
Attached
Detach File
Event Timeline
Log In to Comment