summaryrefslogtreecommitdiff
path: root/coreutils/date.c
diff options
context:
space:
mode:
authorEric Andersen2004-10-11 20:52:16 +0000
committerEric Andersen2004-10-11 20:52:16 +0000
commit9315842242f18e3c5cf706b2bb349757928b2b40 (patch)
tree55f84605486d6b9652e59ad35cd16c2509c9db1e /coreutils/date.c
parent62e0037d2d626f539502821509f0d24b589fbca0 (diff)
downloadbusybox-9315842242f18e3c5cf706b2bb349757928b2b40.zip
busybox-9315842242f18e3c5cf706b2bb349757928b2b40.tar.gz
Patch from David Daney:
It seems that date -s MMDDHHMMYYYY.ss will ignore the .ss part. This patch tries to fix the problem. David Daney.
Diffstat (limited to 'coreutils/date.c')
-rw-r--r--coreutils/date.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/coreutils/date.c b/coreutils/date.c
index 26251c3..3608df6 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -47,6 +47,7 @@
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
+ char *cp;
nr = sscanf(t_string, "%2d%2d%2d%2d%d", &(tm_time->tm_mon),
&(tm_time->tm_mday), &(tm_time->tm_hour), &(tm_time->tm_min),
@@ -56,6 +57,14 @@ static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
bb_error_msg_and_die(bb_msg_invalid_date, t_string);
}
+ cp = strchr(t_string, '.');
+ if (cp) {
+ nr = sscanf(cp + 1, "%2d", &(tm_time->tm_sec));
+ if (nr != 1) {
+ bb_error_msg_and_die(bb_msg_invalid_date, t_string);
+ }
+ }
+
/* correct for century - minor Y2K problem here? */
if (tm_time->tm_year >= 1900) {
tm_time->tm_year -= 1900;