Date: Wed, 2 May 2001 02:57:00 -0700 (PDT) From: thz@lennartz-electronic.de To: freebsd-gnats-submit@FreeBSD.org Subject: bin/27029: strptime: %s formatting missing (patch) Message-ID: <200105020957.f429v0e11951@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 27029 >Category: bin >Synopsis: strptime: %s formatting missing (patch) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 02 03:00:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Thomas Zenker >Release: 4.3-STABLE >Organization: Lennartz electronic >Environment: FreeBSD mezcal.tue.le 4.3-STABLE FreeBSD 4.3-STABLE #6: Wed May 2 08:50:01 CEST 2001 root@mezcal.tue.le:/usr/obj/usr/src/sys/MEZCAL i386 >Description: for date manipulations in ascii form is documented, that all formattings of date (resp. strftime) can be read by strptime. However, the "%s" format (seconds UTC since epoch) is not recognized. A patch, which integrates this format is supplied. >How-To-Repeat: date -j -f "%s" `date "+%s"` >Fix: Index: lib/libc/stdtime/strptime.c =================================================================== RCS file: /usr/cvs/FreeBSD/src/lib/libc/stdtime/strptime.c,v retrieving revision 1.17.2.1 diff -u -r1.17.2.1 strptime.c --- lib/libc/stdtime/strptime.c 2000/10/26 16:07:53 1.17.2.1 +++ lib/libc/stdtime/strptime.c 2001/04/27 19:38:51 @@ -513,6 +513,16 @@ } } break; + case 's': + { + time_t t; + const char *cp; + t = strtol(buf, &cp, 10); + buf = cp; + memcpy(tm, gmtime(&t), sizeof(struct tm)); + got_GMT = 1; + } + break; } } return (char *)buf; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105020957.f429v0e11951>