From owner-svn-src-head@freebsd.org Tue Nov 20 00:06:54 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 853BC112FF8B; Tue, 20 Nov 2018 00:06:54 +0000 (UTC) (envelope-from tmunro@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 121B76B96A; Tue, 20 Nov 2018 00:06:54 +0000 (UTC) (envelope-from tmunro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DCF0112BD; Tue, 20 Nov 2018 00:06:53 +0000 (UTC) (envelope-from tmunro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAK06rui070630; Tue, 20 Nov 2018 00:06:53 GMT (envelope-from tmunro@FreeBSD.org) Received: (from tmunro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAK06rcl070629; Tue, 20 Nov 2018 00:06:53 GMT (envelope-from tmunro@FreeBSD.org) Message-Id: <201811200006.wAK06rcl070629@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tmunro set sender to tmunro@FreeBSD.org using -f From: Thomas Munro Date: Tue, 20 Nov 2018 00:06:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340655 - head/usr.bin/pom X-SVN-Group: head X-SVN-Commit-Author: tmunro X-SVN-Commit-Paths: head/usr.bin/pom X-SVN-Commit-Revision: 340655 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 121B76B96A X-Spamd-Result: default: False [0.35 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_SHORT(0.33)[0.334,0]; NEURAL_SPAM_MEDIUM(0.02)[0.018,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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, 20 Nov 2018 00:06:54 -0000 Author: tmunro Date: Tue Nov 20 00:06:53 2018 New Revision: 340655 URL: https://svnweb.freebsd.org/changeset/base/340655 Log: pom: Fix fencepost bugs. Under some conditions pom would report "waning" and then "full", show higher percentages than it should, and get confused by DST. Fix. Before: 2018.01.30: The Moon is Waxing Gibbous (97% of Full) 2018.01.31: The Moon is Waning Gibbous (100% of Full) 2018.02.01: The Moon is Full 2018.02.02: The Moon is Waning Gibbous (98% of Full) After: 2018.01.30: The Moon is Waxing Gibbous (96% of Full) 2018.01.31: The Moon is Waxing Gibbous (99% of Full) 2018.02.01: The Moon is Full 2018.02.02: The Moon is Waning Gibbous (97% of Full) PR: 231705 Submitted by: Andrew Gierth Approved by: allanjude (mentor) MFC after: 2 weeks Differential Revision: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231705 Modified: head/usr.bin/pom/pom.c Modified: head/usr.bin/pom/pom.c ============================================================================== --- head/usr.bin/pom/pom.c Mon Nov 19 23:56:33 2018 (r340654) +++ head/usr.bin/pom/pom.c Tue Nov 20 00:06:53 2018 (r340655) @@ -135,11 +135,13 @@ main(int argc, char **argv) tmd.tm_hour = 0; tmd.tm_min = 0; tmd.tm_sec = 0; + tmd.tm_isdst = -1; } if (otime != NULL) { tmd.tm_hour = strtol(otime, NULL, 10); tmd.tm_min = strtol(otime + 3, NULL, 10); tmd.tm_sec = strtol(otime + 6, NULL, 10); + tmd.tm_isdst = -1; } tt = mktime(&tmd); } @@ -149,19 +151,19 @@ main(int argc, char **argv) (GMT.tm_min / 60.0) + (GMT.tm_sec / 3600.0)) / 24.0); for (cnt = EPOCH; cnt < GMT.tm_year; ++cnt) days += isleap(1900 + cnt) ? 366 : 365; - today = potm(days) + .5; + today = potm(days); if (pflag) { (void)printf("%1.0f\n", today); return (0); } (void)printf("The Moon is "); - if ((int)today == 100) + if (today >= 99.5) (void)printf("Full\n"); - else if (!(int)today) + else if (today < 0.5) (void)printf("New\n"); else { tomorrow = potm(days + 1); - if ((int)today == 50) + if (today >= 49.5 && today < 50.5) (void)printf("%s\n", tomorrow > today ? "at the First Quarter" : "at the Last Quarter"); else {