System.Globalization.GregorianCalendarHelper.GetEra C# (CSharp) Méthode

GetEra() public méthode

public GetEra ( System.DateTime time ) : int
time System.DateTime
Résultat int
        public int GetEra(DateTime time)
        {
            long ticks = time.Ticks;
            // The assumption here is that m_EraInfo is listed in reverse order.
            for (int i = 0; i < m_EraInfo.Length; i++) {
                if (ticks >= m_EraInfo[i].ticks) {
                    return (m_EraInfo[i].era);
                }
            }
            throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_Era"));
        }

Usage Example

Exemple #1
0
        /*=================================GetEra==========================
         **Action: Get the era value of the specified time.
         **Returns: The era value for the specified time.
         **Arguments:
         **      time the specified date time.
         **Exceptions: ArgumentOutOfRangeException if time is out of the valid era ranges.
         **============================================================================*/


        public override int GetEra(DateTime time)
        {
            return(helper.GetEra(time));
        }