< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/lib/ExsltDatetime.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xalan.internal.lib;
  23 


 599     {
 600       String[] edz = getEraDatetimeZone(datetimeIn);
 601       String datetime = edz[1];
 602       if (datetime == null)
 603         return new XNumber(Double.NaN);
 604 
 605       String[] formats = {dt, d, gym, gy};
 606       double dbl = getNumber(datetime, formats, Calendar.YEAR);
 607       if (dbl == Double.NaN)
 608         return new XNumber(Double.NaN);
 609       int yr = (int)dbl;
 610       return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
 611     }
 612 
 613     /**
 614      * See above.
 615      */
 616     public static boolean leapYear()
 617     {
 618       Calendar cal = Calendar.getInstance();
 619       int yr = (int)cal.get(Calendar.YEAR);
 620       return (yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
 621     }
 622 
 623     /**
 624      * The date:month-name function returns the full name of the month of a date.
 625      * If no argument is given, then the current local date/time, as returned by
 626      * date:date-time is used the default argument.
 627      * The date/time string specified as the argument is a left or right-truncated
 628      * string in the format defined as the lexical representation of xs:dateTime in
 629      *  one of the formats defined in
 630      * <a href="http://www.w3.org/TR/xmlschema-2/">[XML Schema Part 2: Datatypes]</a>.
 631      * The permitted formats are as follows:
 632      *    xs:dateTime (CCYY-MM-DDThh:mm:ss)
 633      *    xs:date (CCYY-MM-DD)
 634      *    xs:gYearMonth (CCYY-MM)
 635      *    xs:gMonth (--MM--)
 636      * If the date/time string is not in one of these formats, then an empty string ('')
 637      * is returned.
 638      * The result is an English month name: one of 'January', 'February', 'March',
 639      * 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November'


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xalan.internal.lib;
  23 


 599     {
 600       String[] edz = getEraDatetimeZone(datetimeIn);
 601       String datetime = edz[1];
 602       if (datetime == null)
 603         return new XNumber(Double.NaN);
 604 
 605       String[] formats = {dt, d, gym, gy};
 606       double dbl = getNumber(datetime, formats, Calendar.YEAR);
 607       if (dbl == Double.NaN)
 608         return new XNumber(Double.NaN);
 609       int yr = (int)dbl;
 610       return new XBoolean(yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
 611     }
 612 
 613     /**
 614      * See above.
 615      */
 616     public static boolean leapYear()
 617     {
 618       Calendar cal = Calendar.getInstance();
 619       int yr = cal.get(Calendar.YEAR);
 620       return (yr % 400 == 0 || (yr % 100 != 0 && yr % 4 == 0));
 621     }
 622 
 623     /**
 624      * The date:month-name function returns the full name of the month of a date.
 625      * If no argument is given, then the current local date/time, as returned by
 626      * date:date-time is used the default argument.
 627      * The date/time string specified as the argument is a left or right-truncated
 628      * string in the format defined as the lexical representation of xs:dateTime in
 629      *  one of the formats defined in
 630      * <a href="http://www.w3.org/TR/xmlschema-2/">[XML Schema Part 2: Datatypes]</a>.
 631      * The permitted formats are as follows:
 632      *    xs:dateTime (CCYY-MM-DDThh:mm:ss)
 633      *    xs:date (CCYY-MM-DD)
 634      *    xs:gYearMonth (CCYY-MM)
 635      *    xs:gMonth (--MM--)
 636      * If the date/time string is not in one of these formats, then an empty string ('')
 637      * is returned.
 638      * The result is an English month name: one of 'January', 'February', 'March',
 639      * 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November'


< prev index next >