From nobody@FreeBSD.org  Sat Oct 12 00:55:07 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E6D7A37B401
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Oct 2002 00:55:07 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A575043E91
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Oct 2002 00:55:07 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g9C7sH7R004814
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Oct 2002 00:54:17 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.6/8.12.6/Submit) id g9C7sHGV004813;
	Sat, 12 Oct 2002 00:54:17 -0700 (PDT)
Message-Id: <200210120754.g9C7sHGV004813@www.freebsd.org>
Date: Sat, 12 Oct 2002 00:54:17 -0700 (PDT)
From: Zong Li <zong.li@attbi.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: The "date" command takes invalid input when it is used to set system date or clock.
X-Send-Pr-Version: www-1.0

>Number:         43957
>Category:       misc
>Synopsis:       The "date" command takes invalid input when it is used to set system date or clock.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 12 01:00:09 PDT 2002
>Closed-Date:    Sat Oct 12 10:19:39 PDT 2002
>Last-Modified:  Sat Oct 12 10:19:39 PDT 2002
>Originator:     Zong Li
>Release:        FreeBSD 4.6-RELEASE
>Organization:
Redlinenetworks
>Environment:
FreeBSD 4.6-RELEASE FreeBSD 4.6-RELEASE #2: Mon Jul 15 11:30:11 PDT 2002     root@FreeBSD:/usr/src/sys/compile/MYKERNEL  i386

>Description:
Due to some date input formats simply use numbers (02 for Feb., 08 for Aug. etc.), a typo in date input may cause the system set to an incorrect date. This may cause some confusion or potential problem in applications that tightly relied or related to system date/clock settings.
>How-To-Repeat:
If I want to set the system date/clock to be March 31, 2002, 12:45, but typoed as the following:
FreeBSD# date 0202311245
Sun Mar  3 12:45:00 PST 2002 <<<< It was set to March 3, 2002.
FreeBSD# date 0211311245   <<< typoed Dec. (12) as Nov (11)
Sun Dec  1 12:45:00 PST 2002 
FreeBSD# date
Sun Dec  1 12:45:05 PST 2002  <<<< It was set to Dec 1, 2002.
FreeBSD# 

>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: schweikh 
State-Changed-When: Sat Oct 12 10:12:57 PDT 2002 
State-Changed-Why:  
Not a bug. You specify an invalid date (Nov 31). Technically 
this is a case of "undefined behavior". In particular, turning 
Nov 31 to Dec 1 could even be regarded as a feature: it is 
consistent with the normalization done by mktime(3): 

The original values of the tm_wday and tm_yday components of the struc- 
ture are ignored, and the original values of the other components are not 
restricted to their normal ranges, and will be normalized if needed.  For 
example, October 40 is changed into November 9, a tm_hour of -1 means 1 
hour before midnight, tm_mday of 0 means the day preceding the current 
month, and tm_mon of -2 means 2 months before January of tm_year. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43957 
>Unformatted:
