aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/pom/pom.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@FreeBSD.org>2018-11-20 00:06:53 +0000
committerThomas Munro <tmunro@FreeBSD.org>2018-11-20 00:06:53 +0000
commitd1f84ec0a7670692af788ca32d1d6c21011454b8 (patch)
treeaf0ee938fde5e4d96077cecf6a3ba887e348b0d4 /usr.bin/pom/pom.c
parentf5d03775e06fb7133089b1e5ffa1a30df535d129 (diff)
downloadsrc-d1f84ec0a7670692af788ca32d1d6c21011454b8.tar.gz
src-d1f84ec0a7670692af788ca32d1d6c21011454b8.zip
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
Notes
Notes: svn path=/head/; revision=340655
Diffstat (limited to 'usr.bin/pom/pom.c')
-rw-r--r--usr.bin/pom/pom.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/pom/pom.c b/usr.bin/pom/pom.c
index 5c95dcda6add..8e7bf8d8f84e 100644
--- a/usr.bin/pom/pom.c
+++ b/usr.bin/pom/pom.c
@@ -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 {