diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-15 10:42:17 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-15 10:42:17 +0200 |
commit | f2710d02210bbba4a9580c11ff053b01081eaf54 (patch) | |
tree | fe18f6f4f483c3180e46ed00df7c0531e3be5c97 /coreutils/date.c | |
parent | 05e8605ab8a01120af7c9f011c2334ab34381fdf (diff) | |
download | busybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.tar.gz busybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.tar.bz2 busybox-w32-f2710d02210bbba4a9580c11ff053b01081eaf54.zip |
date: move applet and usage bits to date.c
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'coreutils/date.c')
-rw-r--r-- | coreutils/date.c | 106 |
1 files changed, 74 insertions, 32 deletions
diff --git a/coreutils/date.c b/coreutils/date.c index c9dfedf81..87cc8f2ef 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -19,38 +19,7 @@ | |||
19 | /* Input parsing code is always bulky - used heavy duty libc stuff as | 19 | /* Input parsing code is always bulky - used heavy duty libc stuff as |
20 | much as possible, missed out a lot of bounds checking */ | 20 | much as possible, missed out a lot of bounds checking */ |
21 | 21 | ||
22 | /* Default input handling to save surprising some people */ | 22 | //applet:IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP)) |
23 | |||
24 | /* GNU coreutils 6.9 man page: | ||
25 | * date [OPTION]... [+FORMAT] | ||
26 | * date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] | ||
27 | * -d, --date=STRING | ||
28 | * display time described by STRING, not `now' | ||
29 | * -f, --file=DATEFILE | ||
30 | * like --date once for each line of DATEFILE | ||
31 | * -r, --reference=FILE | ||
32 | * display the last modification time of FILE | ||
33 | * -R, --rfc-2822 | ||
34 | * output date and time in RFC 2822 format. | ||
35 | * Example: Mon, 07 Aug 2006 12:34:56 -0600 | ||
36 | * --rfc-3339=TIMESPEC | ||
37 | * output date and time in RFC 3339 format. | ||
38 | * TIMESPEC='date', 'seconds', or 'ns' | ||
39 | * Date and time components are separated by a single space: | ||
40 | * 2006-08-07 12:34:56-06:00 | ||
41 | * -s, --set=STRING | ||
42 | * set time described by STRING | ||
43 | * -u, --utc, --universal | ||
44 | * print or set Coordinated Universal Time | ||
45 | * | ||
46 | * Busybox: | ||
47 | * long options are not supported | ||
48 | * -f is not supported | ||
49 | * -I seems to roughly match --rfc-3339, but -I has _optional_ param | ||
50 | * (thus "-I seconds" doesn't work, only "-Iseconds"), | ||
51 | * and does not support -Ins | ||
52 | * -D FMT is a bbox extension for _input_ conversion of -d DATE | ||
53 | */ | ||
54 | 23 | ||
55 | //kbuild:lib-$(CONFIG_DATE) += date.o | 24 | //kbuild:lib-$(CONFIG_DATE) += date.o |
56 | 25 | ||
@@ -69,6 +38,7 @@ | |||
69 | //config: Enable option (-I) to output an ISO-8601 compliant | 38 | //config: Enable option (-I) to output an ISO-8601 compliant |
70 | //config: date/time string. | 39 | //config: date/time string. |
71 | //config: | 40 | //config: |
41 | //config:# defaults to "no": stat's nanosecond field is a bit non-portable | ||
72 | //config:config FEATURE_DATE_NANO | 42 | //config:config FEATURE_DATE_NANO |
73 | //config: bool "Support %[num]N nanosecond format specifier" | 43 | //config: bool "Support %[num]N nanosecond format specifier" |
74 | //config: default n | 44 | //config: default n |
@@ -92,6 +62,78 @@ | |||
92 | //config: the same format. With it on, 'date DATE' additionally supports | 62 | //config: the same format. With it on, 'date DATE' additionally supports |
93 | //config: MMDDhhmm[[YY]YY][.ss] format. | 63 | //config: MMDDhhmm[[YY]YY][.ss] format. |
94 | 64 | ||
65 | /* GNU coreutils 6.9 man page: | ||
66 | * date [OPTION]... [+FORMAT] | ||
67 | * date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] | ||
68 | * -d, --date=STRING | ||
69 | * display time described by STRING, not `now' | ||
70 | * -f, --file=DATEFILE | ||
71 | * like --date once for each line of DATEFILE | ||
72 | * -r, --reference=FILE | ||
73 | * display the last modification time of FILE | ||
74 | * -R, --rfc-2822 | ||
75 | * output date and time in RFC 2822 format. | ||
76 | * Example: Mon, 07 Aug 2006 12:34:56 -0600 | ||
77 | * --rfc-3339=TIMESPEC | ||
78 | * output date and time in RFC 3339 format. | ||
79 | * TIMESPEC='date', 'seconds', or 'ns' | ||
80 | * Date and time components are separated by a single space: | ||
81 | * 2006-08-07 12:34:56-06:00 | ||
82 | * -s, --set=STRING | ||
83 | * set time described by STRING | ||
84 | * -u, --utc, --universal | ||
85 | * print or set Coordinated Universal Time | ||
86 | * | ||
87 | * Busybox: | ||
88 | * long options are not supported | ||
89 | * -f is not supported | ||
90 | * -I seems to roughly match --rfc-3339, but -I has _optional_ param | ||
91 | * (thus "-I seconds" doesn't work, only "-Iseconds"), | ||
92 | * and does not support -Ins | ||
93 | * -D FMT is a bbox extension for _input_ conversion of -d DATE | ||
94 | */ | ||
95 | |||
96 | //usage:#define date_trivial_usage | ||
97 | //usage: "[OPTIONS] [+FMT] [TIME]" | ||
98 | //usage:#define date_full_usage "\n\n" | ||
99 | //usage: "Display time (using +FMT), or set time\n" | ||
100 | //usage: "\nOptions:" | ||
101 | //usage: IF_NOT_LONG_OPTS( | ||
102 | //usage: "\n [-s] TIME Set time to TIME" | ||
103 | //usage: "\n -u Work in UTC (don't convert to local time)" | ||
104 | //usage: "\n -R Output RFC-2822 compliant date string" | ||
105 | //usage: ) IF_LONG_OPTS( | ||
106 | //usage: "\n [-s,--set] TIME Set time to TIME" | ||
107 | //usage: "\n -u,--utc Work in UTC (don't convert to local time)" | ||
108 | //usage: "\n -R,--rfc-2822 Output RFC-2822 compliant date string" | ||
109 | //usage: ) | ||
110 | //usage: IF_FEATURE_DATE_ISOFMT( | ||
111 | //usage: "\n -I[SPEC] Output ISO-8601 compliant date string" | ||
112 | //usage: "\n SPEC='date' (default) for date only," | ||
113 | //usage: "\n 'hours', 'minutes', or 'seconds' for date and" | ||
114 | //usage: "\n time to the indicated precision" | ||
115 | //usage: ) | ||
116 | //usage: IF_NOT_LONG_OPTS( | ||
117 | //usage: "\n -r FILE Display last modification time of FILE" | ||
118 | //usage: "\n -d TIME Display TIME, not 'now'" | ||
119 | //usage: ) IF_LONG_OPTS( | ||
120 | //usage: "\n -r,--reference FILE Display last modification time of FILE" | ||
121 | //usage: "\n -d,--date TIME Display TIME, not 'now'" | ||
122 | //usage: ) | ||
123 | //usage: IF_FEATURE_DATE_ISOFMT( | ||
124 | //usage: "\n -D FMT Use FMT for -d TIME conversion" | ||
125 | //usage: ) | ||
126 | //usage: "\n" | ||
127 | //usage: "\nRecognized TIME formats:" | ||
128 | //usage: "\n hh:mm[:ss]" | ||
129 | //usage: "\n [YYYY.]MM.DD-hh:mm[:ss]" | ||
130 | //usage: "\n YYYY-MM-DD hh:mm[:ss]" | ||
131 | //usage: "\n [[[[[YY]YY]MM]DD]hh]mm[.ss]" | ||
132 | //usage: | ||
133 | //usage:#define date_example_usage | ||
134 | //usage: "$ date\n" | ||
135 | //usage: "Wed Apr 12 18:52:41 MDT 2000\n" | ||
136 | |||
95 | #include "libbb.h" | 137 | #include "libbb.h" |
96 | #if ENABLE_FEATURE_DATE_NANO | 138 | #if ENABLE_FEATURE_DATE_NANO |
97 | # include <sys/syscall.h> | 139 | # include <sys/syscall.h> |