LCOV - code coverage report
Current view: top level - intl/icu/source/i18n - cecal.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 42 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // © 2016 and later: Unicode, Inc. and others.
       2             : // License & terms of use: http://www.unicode.org/copyright.html
       3             : /*
       4             : *******************************************************************************
       5             : * Copyright (C) 2003 - 2009, International Business Machines Corporation and  *
       6             : * others. All Rights Reserved.                                                *
       7             : *******************************************************************************
       8             : */
       9             : 
      10             : #include "unicode/utypes.h"
      11             : 
      12             : #if !UCONFIG_NO_FORMATTING
      13             : 
      14             : #include "cecal.h"
      15             : #include "gregoimp.h"   //Math
      16             : 
      17             : U_NAMESPACE_BEGIN
      18             : 
      19             : static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
      20             :     // Minimum  Greatest    Least  Maximum
      21             :     //           Minimum  Maximum
      22             :     {        0,        0,        1,        1}, // ERA
      23             :     {        1,        1,  5000000,  5000000}, // YEAR
      24             :     {        0,        0,       12,       12}, // MONTH
      25             :     {        1,        1,       52,       53}, // WEEK_OF_YEAR
      26             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // WEEK_OF_MONTH
      27             :     {        1,        1,        5,       30}, // DAY_OF_MONTH
      28             :     {        1,        1,      365,      366}, // DAY_OF_YEAR
      29             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // DAY_OF_WEEK
      30             :     {       -1,       -1,        1,        5}, // DAY_OF_WEEK_IN_MONTH
      31             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // AM_PM
      32             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // HOUR
      33             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // HOUR_OF_DAY
      34             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MINUTE
      35             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // SECOND
      36             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECOND
      37             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // ZONE_OFFSET
      38             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // DST_OFFSET
      39             :     { -5000000, -5000000,  5000000,  5000000}, // YEAR_WOY
      40             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // DOW_LOCAL
      41             :     { -5000000, -5000000,  5000000,  5000000}, // EXTENDED_YEAR
      42             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // JULIAN_DAY
      43             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // MILLISECONDS_IN_DAY
      44             :     {/*N/A*/-1,/*N/A*/-1,/*N/A*/-1,/*N/A*/-1}, // IS_LEAP_MONTH
      45             : };
      46             : 
      47             : //-------------------------------------------------------------------------
      48             : // Constructors...
      49             : //-------------------------------------------------------------------------
      50             : 
      51           0 : CECalendar::CECalendar(const Locale& aLocale, UErrorCode& success)
      52           0 : :   Calendar(TimeZone::createDefault(), aLocale, success)
      53             : {
      54           0 :     setTimeInMillis(getNow(), success);
      55           0 : }
      56             : 
      57           0 : CECalendar::CECalendar (const CECalendar& other) 
      58           0 : :   Calendar(other)
      59             : {
      60           0 : }
      61             : 
      62           0 : CECalendar::~CECalendar()
      63             : {
      64           0 : }
      65             : 
      66             : CECalendar&
      67           0 : CECalendar::operator=(const CECalendar& right)
      68             : {
      69           0 :     Calendar::operator=(right);
      70           0 :     return *this;
      71             : }
      72             : 
      73             : //-------------------------------------------------------------------------
      74             : // Calendar framework
      75             : //-------------------------------------------------------------------------
      76             : 
      77             : int32_t
      78           0 : CECalendar::handleComputeMonthStart(int32_t eyear,int32_t emonth, UBool /*useMonth*/) const
      79             : {
      80           0 :     return ceToJD(eyear, emonth, 0, getJDEpochOffset());
      81             : }
      82             : 
      83             : int32_t
      84           0 : CECalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const
      85             : {
      86           0 :     return LIMITS[field][limitType];
      87             : }
      88             : 
      89             : UBool
      90           0 : CECalendar::inDaylightTime(UErrorCode& status) const
      91             : {
      92           0 :     if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) {
      93           0 :         return FALSE;
      94             :     }
      95             : 
      96             :     // Force an update of the state of the Calendar.
      97           0 :     ((CECalendar*)this)->complete(status); // cast away const
      98             : 
      99           0 :     return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
     100             : }
     101             : 
     102             : UBool
     103           0 : CECalendar::haveDefaultCentury() const
     104             : {
     105           0 :     return TRUE;
     106             : }
     107             : 
     108             : //-------------------------------------------------------------------------
     109             : // Calendar system Conversion methods...
     110             : //-------------------------------------------------------------------------
     111             : int32_t
     112           0 : CECalendar::ceToJD(int32_t year, int32_t month, int32_t date, int32_t jdEpochOffset)
     113             : {
     114             :     // handle month > 12, < 0 (e.g. from add/set)
     115           0 :     if ( month >= 0 ) {
     116           0 :         year += month/13;
     117           0 :         month %= 13;
     118             :     } else {
     119           0 :         ++month;
     120           0 :         year += month/13 - 1;
     121           0 :         month = month%13 + 12;
     122             :     }
     123             :     return (int32_t) (
     124             :         jdEpochOffset                   // difference from Julian epoch to 1,1,1
     125           0 :         + 365 * year                    // number of days from years
     126           0 :         + ClockMath::floorDivide(year, 4)    // extra day of leap year
     127           0 :         + 30 * month                    // number of days from months (months are 0-based)
     128           0 :         + date - 1                      // number of days for present month (1 based)
     129           0 :         );
     130             : }
     131             : 
     132             : void
     133           0 : CECalendar::jdToCE(int32_t julianDay, int32_t jdEpochOffset, int32_t& year, int32_t& month, int32_t& day)
     134             : {
     135             :     int32_t c4; // number of 4 year cycle (1461 days)
     136             :     int32_t r4; // remainder of 4 year cycle, always positive
     137             : 
     138           0 :     c4 = ClockMath::floorDivide(julianDay - jdEpochOffset, 1461, r4);
     139             : 
     140           0 :     year = 4 * c4 + (r4/365 - r4/1460); // 4 * <number of 4year cycle> + <years within the last cycle>
     141             : 
     142           0 :     int32_t doy = (r4 == 1460) ? 365 : (r4 % 365); // days in present year
     143             : 
     144           0 :     month = doy / 30;       // 30 -> Coptic/Ethiopic month length up to 12th month
     145           0 :     day = (doy % 30) + 1;   // 1-based days in a month
     146           0 : }
     147             : 
     148             : U_NAMESPACE_END
     149             : 
     150             : #endif /* #if !UCONFIG_NO_FORMATTING */
     151             : //eof

Generated by: LCOV version 1.13