1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
566 params[1] = dom;
567 params[2] = 0;
568 } else {
569 // ZoneRulesBuilder adjusts < 0 case (-1, for last, don't have
570 // "<=" case yet) to positive value if not February (it appears
571 // we don't have February cutoff in tzdata table yet)
572 // Ideally, if JSR310 can just pass in the nagative and
573 // we can then pass in the dom = -1, dow > 0 into ZoneInfo
574 //
575 // hacking, assume the >=24 is the result of ZRB optimization for
576 // "last", it works for now.
577 if (dom < 0 || dom >= 24) {
578 params[1] = -1;
579 params[2] = toCalendarDOW[dow];
580 } else {
581 params[1] = dom;
582 // To specify a day of week on or after an exact day of month,
583 // set the month to an exact month value, day-of-month to the
584 // day on or after which the rule is applied, and day-of-week
585 // to a negative Calendar.DAY_OF_WEEK DAY_OF_WEEK field value.
586 params[2] = -toCalendarDOW[dow];
587 }
588 }
589 params[3] = startRule.secondOfDay * 1000;
590 params[4] = toSTZTime[startRule.timeDefinition];
591 params[5] = endRule.month - 1;
592 dom = endRule.dom;
593 dow = endRule.dow;
594 if (dow == -1) {
595 params[6] = dom;
596 params[7] = 0;
597 } else {
598 // hacking: see comment above
599 if (dom < 0 || dom >= 24) {
600 params[6] = -1;
601 params[7] = toCalendarDOW[dow];
602 } else {
603 params[6] = dom;
604 params[7] = -toCalendarDOW[dow];
605 }
|
1 /*
2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
566 params[1] = dom;
567 params[2] = 0;
568 } else {
569 // ZoneRulesBuilder adjusts < 0 case (-1, for last, don't have
570 // "<=" case yet) to positive value if not February (it appears
571 // we don't have February cutoff in tzdata table yet)
572 // Ideally, if JSR310 can just pass in the nagative and
573 // we can then pass in the dom = -1, dow > 0 into ZoneInfo
574 //
575 // hacking, assume the >=24 is the result of ZRB optimization for
576 // "last", it works for now.
577 if (dom < 0 || dom >= 24) {
578 params[1] = -1;
579 params[2] = toCalendarDOW[dow];
580 } else {
581 params[1] = dom;
582 // To specify a day of week on or after an exact day of month,
583 // set the month to an exact month value, day-of-month to the
584 // day on or after which the rule is applied, and day-of-week
585 // to a negative Calendar.DAY_OF_WEEK DAY_OF_WEEK field value.
586 params[2] = -toCalendarDOW[dow];
587 }
588 // Special case for Asia/Gaza and Asia/Hebron following Palestine
589 // rule where the above hacking of "dom >= 24" won't work.
590 if (zoneId.equals("Asia/Gaza") || zoneId.equals("Asia/Hebron")) {
591 params[1] = dom;
592 params[2] = -toCalendarDOW[dow];
593 }
594 }
595 params[3] = startRule.secondOfDay * 1000;
596 params[4] = toSTZTime[startRule.timeDefinition];
597 params[5] = endRule.month - 1;
598 dom = endRule.dom;
599 dow = endRule.dow;
600 if (dow == -1) {
601 params[6] = dom;
602 params[7] = 0;
603 } else {
604 // hacking: see comment above
605 if (dom < 0 || dom >= 24) {
606 params[6] = -1;
607 params[7] = toCalendarDOW[dow];
608 } else {
609 params[6] = dom;
610 params[7] = -toCalendarDOW[dow];
611 }
|