Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 104E5200B61 for ; Tue, 9 Aug 2016 17:30:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0EEB3160AA5; Tue, 9 Aug 2016 15:30:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 51A96160A6B for ; Tue, 9 Aug 2016 17:30:05 +0200 (CEST) Received: (qmail 18354 invoked by uid 500); 9 Aug 2016 15:30:04 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 18344 invoked by uid 99); 9 Aug 2016 15:30:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Aug 2016 15:30:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 1B1B3C9C50 for ; Tue, 9 Aug 2016 15:30:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.368 X-Spam-Level: * X-Spam-Status: No, score=1.368 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.432] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Gw3Ahws-ZsxI for ; Tue, 9 Aug 2016 15:30:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id D4AA560D2B for ; Tue, 9 Aug 2016 15:30:02 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1997FE0456 for ; Tue, 9 Aug 2016 15:30:02 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 162033A02BD for ; Tue, 9 Aug 2016 15:30:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1755623 - in /pdfbox/branches/2.0/pdfbox/src: main/java/org/apache/pdfbox/util/DateConverter.java test/java/org/apache/pdfbox/util/TestDateUtil.java Date: Tue, 09 Aug 2016 15:30:02 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160809153002.162033A02BD@svn01-us-west.apache.org> archived-at: Tue, 09 Aug 2016 15:30:06 -0000 Author: tilman Date: Tue Aug 9 15:30:01 2016 New Revision: 1755623 URL: http://svn.apache.org/viewvc?rev=1755623&view=rev Log: PDFBOX-3315: prevent corner case 12:00 to be interpreted as 00:00, fixed + added tests Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java?rev=1755623&r1=1755622&r2=1755623&view=diff ============================================================================== --- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java (original) +++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java Tue Aug 9 15:30:01 2016 @@ -197,12 +197,16 @@ public final class DateConverter } /* - * Constrain a timezone offset to the range [-11:59 thru +11:59]. + * Constrain a timezone offset to the range [-11:59 thru +12:00]. * by adding or subtracting multiples of a full day. */ private static int restrainTZoffset(long proposedOffset) { proposedOffset = ((proposedOffset + HALF_DAY) % DAY + DAY) % DAY; + if (proposedOffset == 0) + { + return HALF_DAY; + } // 0 <= proposedOffset < DAY proposedOffset = (proposedOffset - HALF_DAY) % HALF_DAY; // -HALF_DAY < proposedOffset < HALF_DAY Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java?rev=1755623&r1=1755622&r2=1755623&view=diff ============================================================================== --- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java (original) +++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java Tue Aug 9 15:30:01 2016 @@ -295,6 +295,8 @@ public class TestDateUtil extends TestCa // ambiguous big-endian date checkParse(2073,12,25, 0, 8, 0, 0, 0, "2073 12 25:08"); + // PDFBOX-3315 GMT+12 + checkParse(2016, 4,11,16,01,15, 12, 0, "D:20160411160115+12'00'"); } private static void checkToString(int yr, int mon, int day, @@ -370,6 +372,7 @@ public class TestDateUtil extends TestCa */ public void testParseTZ() { + // 1st parameter is what to expect checkParseTZ(0*HRS+0*MINS, "+00:00"); checkParseTZ(0*HRS+0*MINS, "-0000"); checkParseTZ(1*HRS+0*MINS, "+1:00"); @@ -391,6 +394,9 @@ public class TestDateUtil extends TestCa checkParseTZ((5*HRS+0*MINS), "+0500"); checkParseTZ((11*HRS+0*MINS), "+11'00'"); checkParseTZ(0, "Z"); + // PDFBOX-3315 + checkParseTZ(12*HRS+0*MINS, "+12:00"); + checkParseTZ(12*HRS+0*MINS, "-12:00"); } private static void checkFormatOffset(double off, String expect) @@ -405,6 +411,7 @@ public class TestDateUtil extends TestCa */ public void testFormatTZoffset() { + // 2nd parameter is what to expect checkFormatOffset(-12.1, "+11:54"); checkFormatOffset(12.1, "-11:54"); checkFormatOffset(0, "+00:00"); @@ -413,8 +420,8 @@ public class TestDateUtil extends TestCa checkFormatOffset(-0.5, "-00:30"); checkFormatOffset(.1, "+00:06"); checkFormatOffset(-0.1, "-00:06"); - checkFormatOffset(-12, "+00:00"); - checkFormatOffset(12, "+00:00"); + checkFormatOffset(-12, "+12:00"); + checkFormatOffset(12, "+12:00"); checkFormatOffset(-11.5, "-11:30"); checkFormatOffset(11.5, "+11:30"); checkFormatOffset(11.9, "+11:54");