From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 22 23:58:48 2015 Return-Path: Delivered-To: freebsd-bugs@nevdull.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 8254E7C0 for ; Mon, 22 Jun 2015 23:58:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 520A1D0B for ; Mon, 22 Jun 2015 23:58:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t5MNwmX1089544 for ; Mon, 22 Jun 2015 23:58:48 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 201062] Calendar did not show Father's day on June 22, 2015 using calendar.usholiday Date: Mon, 22 Jun 2015 23:58:48 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 10.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: comet.berkeley@gmail.com X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2015 23:58:48 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201062 Bug ID: 201062 Summary: Calendar did not show Father's day on June 22, 2015 using calendar.usholiday Product: Base System Version: 10.1-STABLE Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: comet.berkeley@gmail.com Created attachment 158000 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=158000&action=edit Calendar Father's Day patch The calendar.usholiday file contains 42 lines of which 2 are relevant to June 21, 2015: 06/SunThird Father's Day (3rd Sunday of June) 06/21* Summer Solstice My .calendar/calendar file includes this one line: #include And when calendar runs it should show two lines out, one for Father's Day and one for the Solstice: $calendar -t21.6.2015 Jun 21* Summer Solstice I patched the code (calendar.c and parsedata.c) and the problem seems to be fixed. $calendar -t21.6.2015 Jun 21* Summer Solstice Jun 21* Father's Day (3rd Sunday of June) To debug this it was helpful to set the debug_remember flag in the dates.c code. This flag is a global integer and can be set from calendar.c when the -d option (debug) is set. In parsedata.c, the calculation of the first day of the recurring weekdays is wrong as it is trying to calculate a day of the month but will always return an integer in the range 0-6. 0 is always wrong... It was: d = (idayofweek - dow + 8) % 7; But should be: d = (idayofweek - dow + 7) % 7 + 1; Additionally the variable dow can be -1 and when it is the code should probably stop (continue) so a better patch is this: if (dow < 0) continue; d = (idayofweek - dow + 7) % 7 + 1; -- You are receiving this mail because: You are the assignee for the bug.