From owner-svn-src-all@FreeBSD.ORG Tue Oct 7 05:16:12 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF1E610C for ; Tue, 7 Oct 2014 05:16:12 +0000 (UTC) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) (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 352DA2AD for ; Tue, 7 Oct 2014 05:16:11 +0000 (UTC) Received: by mail-la0-f48.google.com with SMTP id gi9so5581798lab.21 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=Nn8JFmV2kNss+I1SeXGu79OTXHSnTcQyx4DLTA2Xm0ehg5o6ouNcKqgv058rgVv2Z9 RJcF16RVBMaUDt969/BDTTY+bEtKZOZZqB8xOCQ8fB5WtOpAEph5q4itaPV8JSsWNsCz PEsnSsuP018ND5fhEvbNAAog/ARBUkzP2yVPZJjkzjwQqxRNRt+nYESXiIQ5g68QJSkg jHhpRlmPXKi0MwLUYqmysIqbHuHihbXPDMc/q1+bzl5bvrVgcMEjSIId8liFQwysCHH0 OuQHERUxPoChWHH1ULBkJOVCK/8VYdWwj3CzbU5LbJ4vuCkUCGu/NFnArS6upTh0e7ms pjCQ== X-Gm-Message-State: ALoCoQnBLj2KI4NmBt5fwrLYL9fuUy8klcTbuBok5EzPLasqGPEbnzVGcpxcySF56HTP+PyVikZR 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-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2014 05:16:12 -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/