From owner-svn-src-head@FreeBSD.ORG Tue Oct 7 05:16:07 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A90E6F1 for ; Tue, 7 Oct 2014 05:16:07 +0000 (UTC) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2D48C2AA for ; Tue, 7 Oct 2014 05:16:06 +0000 (UTC) Received: by mail-la0-f53.google.com with SMTP id gq15so5561907lab.40 for ; Mon, 06 Oct 2014 22:16:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=5rsGmcl4SWZSnYTB963tSohjPmuqx+aGP93L9rWjIDg=; b=gpFAitccV6uzAdUGTIV/TTkxQ19QM8K9f8jqfD28kkzFFiD0GOI2R9xGrJfOSXFVbs /GM6oK25kRXmz1wO9z22UuPQfDrC0MBoBnmM/AofMIz8uCnYYV+Oq6wxRsNRrXqNurA9 yUCUX8l3D7c8f/lwUyb/CoIcTLZ0ZYazmzSvNxMgAmoPlGMVgKsjSFFxwXCGKsd2oEWW AuuPIt8Uh6Go08UJzF0e1CMnHppV5bGCCyrz72DiTch3pCpGw8a2x7RJ2farxKBH9VuZ axQl+47k7DKVSxoPpqV8zke7nhJYwIrq7qwEy6dc7p+yg+MRLjcZgQASU9eCJHjMoO2v rQPQ== X-Gm-Message-State: ALoCoQmwwIHhklA3sybAZVt9onmGjRjac73I9MtaNt+8D0F0PuDRwxriTyqyVQ7uL228F0GQ0738 X-Received: by 10.112.209.2 with SMTP id mi2mr1252235lbc.51.1412658963983; Mon, 06 Oct 2014 22:16:03 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id n4sm6358796lah.2.2014.10.06.22.16.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Oct 2014 22:16:03 -0700 (PDT) Message-ID: <54337712.4090202@freebsd.org> Date: Tue, 07 Oct 2014 09:16:02 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: Ian Lepore Subject: Re: svn commit: r272562 - head/lib/libc/stdtime References: <201410050729.s957TpY9020060@svn.freebsd.org> <1412635524.12052.188.camel@revolution.hippie.lan> In-Reply-To: <1412635524.12052.188.camel@revolution.hippie.lan> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2014 05:16:07 -0000 On 07.10.2014 2:45, Ian Lepore wrote: > Using -1 as an error indicator in time conversions has drawbacks (your > change doesn't make it any better or worse, I'm just whining in > general)... > > revolution > date -ujf "%Y-%m-%dT%H:%M:%S" +%s 1970-01-01T0:0:0 > 0 > revolution > date -ujf "%Y-%m-%dT%H:%M:%S" +%s 1969-12-31T23:59:58 > -2 > revolution > date -ujf "%Y-%m-%dT%H:%M:%S" +%s 1969-12-31T23:59:59 > date: nonexistent time > > If timegm() and mktime() were to set errno in addition to returning -1, > strptime() (and others) could use that to see the difference between > errors and the second immediately before the epoch. I'm not sure of the > standards-related implications of those routines setting errno though. POSIX, Base Specs, Issue 7, mktime says: "If the time since the Epoch cannot be represented, the function shall return the value (time_t)−1 and set errno to indicate the error. ... [EOVERFLOW] The result cannot be represented." But we don't set EOVERFLOW inside timegm or mktime... About negative time_t values, POSIX, Seconds Since the Epoch, says: "...is related to a time represented as seconds since the Epoch... If the year is <1970 or the value is negative, the relationship is undefined." So, we are free to either treat all negative values as errors or set EOVERFLOW in our time functions and add a check to every lib & program since nobody checks it. I'll think about this place more.. -- http://ache.vniz.net/