dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization Gregoria


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization GregorianVariantCalendar.cs,NONE,1.1 HijriCalendar.cs,NONE,1.1 JapaneseCalendar.cs,NONE,1.1 KoreanCalendar.cs,NONE,1.1 TaiwanCalendar.cs,NONE,1.1 ThaiBuddhistCalendar.cs,NONE,1.1
Date: Mon, 21 Apr 2003 19:40:48 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization
In directory subversions:/tmp/cvs-serv28613/runtime/System/Globalization

Added Files:
        GregorianVariantCalendar.cs HijriCalendar.cs 
        JapaneseCalendar.cs KoreanCalendar.cs TaiwanCalendar.cs 
        ThaiBuddhistCalendar.cs 
Log Message:


Implement Gregorian variant calendars such as Japanese, Korean, etc;
stub out the Hijri calendar implementation.


--- NEW FILE ---
/*
 * GregorianVariantCalendar.cs - Implementation of the
 *        "System.Globalization.GregorianVariantCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

// This class is used to implement the Japanese, Korean, Taiwan,
// and ThaiBuddhist calendars, which are all variants of the
// Gregorian calendar, but which differ only in how eras and
// years are calculated.

internal sealed class GregorianVariantCalendar : GregorianCalendar
{
        // Internal state.
        private int twoDigitYearMax;
        private EraRule[] rules;
        private int currentEra;

        // Era rule information.
        public sealed class EraRule
        {
                public int              era;
                public DateTime startEra;
                public DateTime endEra;
                public int              startYear;
                public int              endYear;

                public EraRule(int era, DateTime startEra,
                                           DateTime endEra, int startYear)
                                {
                                        this.era = era;
                                        this.startEra = startEra;
                                        if(endEra != DateTime.MaxValue)
                                        {
                                                this.endEra = endEra - new 
TimeSpan(1);
                                        }
                                        else
                                        {
                                                this.endEra = endEra;
                                        }
                                        this.startYear = startYear;
                                        this.endYear = startYear + (endEra.Year 
- startEra.Year);
                                }

        }; // class EraRule

        // Constructor.
        public GregorianVariantCalendar
                                (int twoDigitYearMax, EraRule[] rules, int 
currentEra)
                        {
                                this.twoDigitYearMax = twoDigitYearMax;
                                this.rules = rules;
                                this.currentEra = currentEra;
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        int value = base.TwoDigitYearMax;
                                        if(value != -1)
                                        {
                                                return value;
                                        }
                                        else
                                        {
                                                // Set the default value.
                                                base.TwoDigitYearMax = 
twoDigitYearMax;
                                                return twoDigitYearMax;
                                        }
                                }
                                set
                                {
                                        if(value < 100 || value > 9999)
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("year", 
_("ArgRange_Year"));
                                        }
                                        base.TwoDigitYearMax = value;
                                }
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        int[] eras = new int [rules.Length];
                                        int posn;
                                        for(posn = 0; posn < rules.Length; 
++posn)
                                        {
                                                eras[posn] = rules[posn].era;
                                        }
                                        return eras;
                                }
                        }

        // Get the year from a DateTime value.
        public override int GetYear(DateTime time)
                        {
                                int posn;
                                for(posn = 0; posn < rules.Length; ++posn)
                                {
                                        if(time >= rules[posn].startEra &&
                                           time <= rules[posn].endEra)
                                        {
                                                return time.Year - 
rules[posn].startEra.Year +
                                                           
rules[posn].startYear;
                                        }
                                }
                                throw new ArgumentException(_("Arg_NoEraYear"));
                        }

        // Map a localized year to a Gregorian year.
        private int ToGregorianYear(int year, int era)
                        {
                                if(year < 1 || year > 9999)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("year", _("ArgRange_Year"));
                                }
                                if(era == CurrentEra)
                                {
                                        era = currentEra;
                                }
                                int posn;
                                for(posn = 0; posn < rules.Length; ++posn)
                                {
                                        if(rules[posn].era == era &&
                                           year >= rules[posn].startYear &&
                                           year <= rules[posn].endYear)
                                        {
                                                return year - 
rules[posn].startYear +
                                                           
rules[posn].startEra.Year;
                                        }
                                }
                                throw new 
ArgumentException(_("Arg_InvalidEra"));
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                return base.GetDaysInYear(ToGregorianYear(year, 
era), ADEra);
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                int posn;
                                for(posn = 0; posn < rules.Length; ++posn)
                                {
                                        if(time >= rules[posn].startEra &&
                                           time <= rules[posn].endEra)
                                        {
                                                return rules[posn].era;
                                        }
                                }
                                throw new ArgumentException(_("Arg_NoEraYear"));
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                return base.GetMonthsInYear
                                        (ToGregorianYear(year, era), ADEra);
                        }

        // Determine if a particular day is a leap day.
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                return base.IsLeapDay(ToGregorianYear(year, 
era),
                                                                          
month, day, ADEra);
                        }

        // Determine if a particular month is a leap month.
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                return base.IsLeapMonth(ToGregorianYear(year, 
era),
                                                                                
month, ADEra);
                        }

        // Determine if a particular year is a leap year.
        public override bool IsLeapYear(int year, int era)
                        {
                                return base.IsLeapYear(ToGregorianYear(year, 
era), ADEra);
                        }

        // Convert a particular time into a DateTime value.
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                return base.ToDateTime(ToGregorianYear(year, 
era),
                                                                           
month, day, hour, minute,
                                                                           
second, millisecond, ADEra);
                        }

}; // class GregorianVariantCalendar

}; // namespace System.Globalization

--- NEW FILE ---
/*
 * HijriCalendar.cs - Implementation of the
 *        "System.Globalization.HijriCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

public class HijriCalendar : Calendar
{
        // The Hijri era.
        public static readonly int HijriEra = 1;

        // Useful constants.
        private const int DefaultTwoDigitMax = 1451;

        // Constructor.
        [TODO]
        public HijriCalendar()
                        {
                                // TODO
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        int[] eras = new int [1];
                                        eras[0] = HijriEra;
                                        return eras;
                                }
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        int value = base.TwoDigitYearMax;
                                        if(value != -1)
                                        {
                                                return value;
                                        }
                                        else
                                        {
                                                // Set the default value.
                                                base.TwoDigitYearMax = 
DefaultTwoDigitMax;
                                                return DefaultTwoDigitMax;
                                        }
                                }
                                set
                                {
                                        if(value < 100 || value > 9999)
                                        {
                                                throw new 
ArgumentOutOfRangeException
                                                        ("year", 
_("ArgRange_Year"));
                                        }
                                        base.TwoDigitYearMax = value;
                                }
                        }

        // Add a time period to a DateTime value.
        [TODO]
        public override DateTime AddMonths(DateTime time, int months)
                        {
                                // TODO
                                return time;
                        }
        public override DateTime AddYears(DateTime time, int years)
                        {
                                // TODO
                                return time;
                        }

        // Extract the components from a DateTime value.
        [TODO]
        public override int GetDayOfMonth(DateTime time)
                        {
                                // TODO
                                return 0;
                        }
        [TODO]
        public override System.DayOfWeek GetDayOfWeek(DateTime time)
                        {
                                // TODO
                                return DayOfWeek.Sunday;
                        }
        [TODO]
        public override int GetDayOfYear(DateTime time)
                        {
                                // TODO
                                return 0;
                        }
        [TODO]
        public override int GetMonth(DateTime time)
                        {
                                // TODO
                                return 0;
                        }
        [TODO]
        public override int GetYear(DateTime time)
                        {
                                // TODO
                                return 0;
                        }

        // Get the number of days in a particular month.
        [TODO]
        public override int GetDaysInMonth(int year, int month, int era)
                        {
                                if(era != CurrentEra && era != HijriEra)
                                {
                                        throw new 
ArgumentException(_("Arg_InvalidEra"));
                                }
                                // TODO
                                return 0;
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                if(year < 1 || year > 9999)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("year", _("ArgRange_Year"));
                                }
                                if(era != CurrentEra && era != HijriEra)
                                {
                                        throw new 
ArgumentException(_("Arg_InvalidEra"));
                                }
                                // TODO
                                return 365;
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                return HijriEra;
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                if(year < 1 || year > 9999)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("year", _("ArgRange_Year"));
                                }
                                if(era != CurrentEra && era != HijriEra)
                                {
                                        throw new 
ArgumentException(_("Arg_InvalidEra"));
                                }
                                // TODO
                                return 12;
                        }

        // Determine if a particular day is a leap day.
        [TODO]
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                if(day < 1 || day > GetDaysInMonth(year, month, 
era))
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("day", _("ArgRange_Day"));
                                }
                                // TODO
                                return false;
                        }

        // Determine if a particular month is a leap month.
        [TODO]
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                if(month < 1 || month > 12)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("month", _("ArgRange_Month"));
                                }
                                // TODO
                                return false;
                        }

        // Determine if a particular year is a leap year.
        [TODO]
        public override bool IsLeapYear(int year, int era)
                        {
                                if(year < 1 || year > 9999)
                                {
                                        throw new ArgumentOutOfRangeException
                                                ("year", _("ArgRange_Year"));
                                }
                                if(era != CurrentEra && era != HijriEra)
                                {
                                        throw new 
ArgumentException(_("Arg_InvalidEra"));
                                }
                                // TODO
                                return false;
                        }

        // Convert a particular time into a DateTime value.
        [TODO]
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                if(era != CurrentEra && era != HijriEra)
                                {
                                        throw new 
ArgumentException(_("Arg_InvalidEra"));
                                }
                                // TODO
                                return new DateTime(year, month, day, hour,
                                                                        minute, 
second, millisecond);
                        }

}; // class HijriCalendar

}; // namespace System.Globalization

--- NEW FILE ---
/*
 * JapaneseCalendar.cs - Implementation of the
 *        "System.Globalization.JapaneseCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

public class JapaneseCalendar : Calendar
{
        // Useful constants.
        private const int DefaultTwoDigitMax = 99;

        // Internal state.
        private GregorianVariantCalendar variant;

        // Constructor.
        public JapaneseCalendar()
                        {
                                GregorianVariantCalendar.EraRule[] rules =
                                        new GregorianVariantCalendar.EraRule[] {
                                                new 
GregorianVariantCalendar.EraRule
                                                        (1,
                                                         new DateTime(1868, 9, 
8),
                                                         new DateTime(1912, 7, 
30),
                                                         1),
                                                new 
GregorianVariantCalendar.EraRule
                                                        (2,
                                                         new DateTime(1912, 7, 
30),
                                                         new DateTime(1926, 12, 
25),
                                                         1),
                                                new 
GregorianVariantCalendar.EraRule
                                                        (3,
                                                         new DateTime(1926, 12, 
25),
                                                         new DateTime(1989, 1, 
7),
                                                         1),
                                                new 
GregorianVariantCalendar.EraRule
                                                        (4,
                                                         new DateTime(1989, 1, 
7),
                                                         DateTime.MaxValue,
                                                         1)
                                        };
                                variant = new GregorianVariantCalendar
                                        (DefaultTwoDigitMax, rules, 4);
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        return variant.Eras;
                                }
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        return variant.TwoDigitYearMax;
                                }
                                set
                                {
                                        variant.TwoDigitYearMax = value;
                                }
                        }

        // Add a time period to a DateTime value.
        public override DateTime AddMonths(DateTime time, int months)
                        {
                                return variant.AddMonths(time, months);
                        }
        public override DateTime AddYears(DateTime time, int years)
                        {
                                return variant.AddYears(time, years);
                        }

        // Extract the components from a DateTime value.
        public override int GetDayOfMonth(DateTime time)
                        {
                                return variant.GetDayOfMonth(time);
                        }
        public override System.DayOfWeek GetDayOfWeek(DateTime time)
                        {
                                return variant.GetDayOfWeek(time);
                        }
        public override int GetDayOfYear(DateTime time)
                        {
                                return variant.GetDayOfYear(time);
                        }
        public override int GetMonth(DateTime time)
                        {
                                return variant.GetMonth(time);
                        }
        public override int GetYear(DateTime time)
                        {
                                return variant.GetYear(time);
                        }

        // Get the number of days in a particular month.
        public override int GetDaysInMonth(int year, int month, int era)
                        {
                                return variant.GetDaysInMonth(year, month, era);
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                return variant.GetDaysInYear(year, era);
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                return variant.GetEra(time);
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                return variant.GetMonthsInYear(year, era);
                        }

        // Determine if a particular day is a leap day.
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                return variant.IsLeapDay(year, month, day, era);
                        }

        // Determine if a particular month is a leap month.
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                return variant.IsLeapMonth(year, month, era);
                        }

        // Determine if a particular year is a leap year.
        public override bool IsLeapYear(int year, int era)
                        {
                                return variant.IsLeapYear(year, era);
                        }

        // Convert a particular time into a DateTime value.
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                return variant.ToDateTime(year, month, day, 
hour, minute,
                                                                                
  second, millisecond, era);
                        }

}; // class JapaneseCalendar

}; // namespace System.Globalization

--- NEW FILE ---
/*
 * KoreanCalendar.cs - Implementation of the
 *        "System.Globalization.KoreanCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

public class KoreanCalendar : Calendar
{
        // The Korean era.
        public const int KoreanEra = 1;

        // Useful constants.
        private const int DefaultTwoDigitMax = 4362;

        // Internal state.
        private GregorianVariantCalendar variant;

        // Constructor.
        public KoreanCalendar()
                        {
                                GregorianVariantCalendar.EraRule[] rules =
                                        new GregorianVariantCalendar.EraRule[] {
                                                new 
GregorianVariantCalendar.EraRule
                                                        (KoreanEra,
                                                         DateTime.MinValue,
                                                         DateTime.MaxValue,
                                                         2334),
                                        };
                                variant = new GregorianVariantCalendar
                                        (DefaultTwoDigitMax, rules, KoreanEra);
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        return variant.Eras;
                                }
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        return variant.TwoDigitYearMax;
                                }
                                set
                                {
                                        variant.TwoDigitYearMax = value;
                                }
                        }

        // Add a time period to a DateTime value.
        public override DateTime AddMonths(DateTime time, int months)
                        {
                                return variant.AddMonths(time, months);
                        }
        public override DateTime AddYears(DateTime time, int years)
                        {
                                return variant.AddYears(time, years);
                        }

        // Extract the components from a DateTime value.
        public override int GetDayOfMonth(DateTime time)
                        {
                                return variant.GetDayOfMonth(time);
                        }
        public override System.DayOfWeek GetDayOfWeek(DateTime time)
                        {
                                return variant.GetDayOfWeek(time);
                        }
        public override int GetDayOfYear(DateTime time)
                        {
                                return variant.GetDayOfYear(time);
                        }
        public override int GetMonth(DateTime time)
                        {
                                return variant.GetMonth(time);
                        }
        public override int GetYear(DateTime time)
                        {
                                return variant.GetYear(time);
                        }

        // Get the number of days in a particular month.
        public override int GetDaysInMonth(int year, int month, int era)
                        {
                                return variant.GetDaysInMonth(year, month, era);
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                return variant.GetDaysInYear(year, era);
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                return variant.GetEra(time);
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                return variant.GetMonthsInYear(year, era);
                        }

        // Determine if a particular day is a leap day.
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                return variant.IsLeapDay(year, month, day, era);
                        }

        // Determine if a particular month is a leap month.
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                return variant.IsLeapMonth(year, month, era);
                        }

        // Determine if a particular year is a leap year.
        public override bool IsLeapYear(int year, int era)
                        {
                                return variant.IsLeapYear(year, era);
                        }

        // Convert a particular time into a DateTime value.
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                return variant.ToDateTime(year, month, day, 
hour, minute,
                                                                                
  second, millisecond, era);
                        }

}; // class KoreanCalendar

}; // namespace System.Globalization

--- NEW FILE ---
/*
 * TaiwanCalendar.cs - Implementation of the
 *        "System.Globalization.TaiwanCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

public class TaiwanCalendar : Calendar
{
        // The Taiwan era.
        public const int TaiwanEra = 1;

        // Useful constants.
        private const int DefaultTwoDigitMax = 99;

        // Internal state.
        private GregorianVariantCalendar variant;

        // Constructor.
        public TaiwanCalendar()
                        {
                                GregorianVariantCalendar.EraRule[] rules =
                                        new GregorianVariantCalendar.EraRule[] {
                                                new 
GregorianVariantCalendar.EraRule
                                                        (TaiwanEra,
                                                         new DateTime(1912, 1, 
1),
                                                         DateTime.MaxValue,
                                                         1),
                                        };
                                variant = new GregorianVariantCalendar
                                        (DefaultTwoDigitMax, rules, TaiwanEra);
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        return variant.Eras;
                                }
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        return variant.TwoDigitYearMax;
                                }
                                set
                                {
                                        variant.TwoDigitYearMax = value;
                                }
                        }

        // Add a time period to a DateTime value.
        public override DateTime AddMonths(DateTime time, int months)
                        {
                                return variant.AddMonths(time, months);
                        }
        public override DateTime AddYears(DateTime time, int years)
                        {
                                return variant.AddYears(time, years);
                        }

        // Extract the components from a DateTime value.
        public override int GetDayOfMonth(DateTime time)
                        {
                                return variant.GetDayOfMonth(time);
                        }
        public override System.DayOfWeek GetDayOfWeek(DateTime time)
                        {
                                return variant.GetDayOfWeek(time);
                        }
        public override int GetDayOfYear(DateTime time)
                        {
                                return variant.GetDayOfYear(time);
                        }
        public override int GetMonth(DateTime time)
                        {
                                return variant.GetMonth(time);
                        }
        public override int GetYear(DateTime time)
                        {
                                return variant.GetYear(time);
                        }

        // Get the number of days in a particular month.
        public override int GetDaysInMonth(int year, int month, int era)
                        {
                                return variant.GetDaysInMonth(year, month, era);
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                return variant.GetDaysInYear(year, era);
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                return variant.GetEra(time);
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                return variant.GetMonthsInYear(year, era);
                        }

        // Determine if a particular day is a leap day.
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                return variant.IsLeapDay(year, month, day, era);
                        }

        // Determine if a particular month is a leap month.
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                return variant.IsLeapMonth(year, month, era);
                        }

        // Determine if a particular year is a leap year.
        public override bool IsLeapYear(int year, int era)
                        {
                                return variant.IsLeapYear(year, era);
                        }

        // Convert a particular time into a DateTime value.
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                return variant.ToDateTime(year, month, day, 
hour, minute,
                                                                                
  second, millisecond, era);
                        }

}; // class TaiwanCalendar

}; // namespace System.Globalization

--- NEW FILE ---
/*
 * ThaiBuddhistCalendar.cs - Implementation of the
 *        "System.Globalization.ThaiBuddhistCalendar" class.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

using System;

public class ThaiBuddhistCalendar : Calendar
{
        // The ThaiBuddhist era.
        public const int ThaiBuddhistEra = 1;

        // Useful constants.
        private const int DefaultTwoDigitMax = 2572;

        // Internal state.
        private GregorianVariantCalendar variant;

        // Constructor.
        public ThaiBuddhistCalendar()
                        {
                                GregorianVariantCalendar.EraRule[] rules =
                                        new GregorianVariantCalendar.EraRule[] {
                                                new 
GregorianVariantCalendar.EraRule
                                                        (ThaiBuddhistEra,
                                                         DateTime.MinValue,
                                                         DateTime.MaxValue,
                                                         544),
                                        };
                                variant = new GregorianVariantCalendar
                                        (DefaultTwoDigitMax, rules, 
ThaiBuddhistEra);
                        }

        // Get a list of eras for the calendar.
        public override int[] Eras
                        {
                                get
                                {
                                        return variant.Eras;
                                }
                        }

        // Set the last year of a 100-year range for 2-digit processing.
        public override int TwoDigitYearMax
                        {
                                get
                                {
                                        return variant.TwoDigitYearMax;
                                }
                                set
                                {
                                        variant.TwoDigitYearMax = value;
                                }
                        }

        // Add a time period to a DateTime value.
        public override DateTime AddMonths(DateTime time, int months)
                        {
                                return variant.AddMonths(time, months);
                        }
        public override DateTime AddYears(DateTime time, int years)
                        {
                                return variant.AddYears(time, years);
                        }

        // Extract the components from a DateTime value.
        public override int GetDayOfMonth(DateTime time)
                        {
                                return variant.GetDayOfMonth(time);
                        }
        public override System.DayOfWeek GetDayOfWeek(DateTime time)
                        {
                                return variant.GetDayOfWeek(time);
                        }
        public override int GetDayOfYear(DateTime time)
                        {
                                return variant.GetDayOfYear(time);
                        }
        public override int GetMonth(DateTime time)
                        {
                                return variant.GetMonth(time);
                        }
        public override int GetYear(DateTime time)
                        {
                                return variant.GetYear(time);
                        }

        // Get the number of days in a particular month.
        public override int GetDaysInMonth(int year, int month, int era)
                        {
                                return variant.GetDaysInMonth(year, month, era);
                        }

        // Get the number of days in a particular year.
        public override int GetDaysInYear(int year, int era)
                        {
                                return variant.GetDaysInYear(year, era);
                        }

        // Get the era for a specific DateTime value.
        public override int GetEra(DateTime time)
                        {
                                return variant.GetEra(time);
                        }

        // Get the number of months in a specific year.
        public override int GetMonthsInYear(int year, int era)
                        {
                                return variant.GetMonthsInYear(year, era);
                        }

        // Determine if a particular day is a leap day.
        public override bool IsLeapDay(int year, int month, int day, int era)
                        {
                                return variant.IsLeapDay(year, month, day, era);
                        }

        // Determine if a particular month is a leap month.
        public override bool IsLeapMonth(int year, int month, int era)
                        {
                                return variant.IsLeapMonth(year, month, era);
                        }

        // Determine if a particular year is a leap year.
        public override bool IsLeapYear(int year, int era)
                        {
                                return variant.IsLeapYear(year, era);
                        }

        // Convert a particular time into a DateTime value.
        public override DateTime ToDateTime(int year, int month, int day,
                                                                                
int hour, int minute, int second,
                                                                                
int millisecond, int era)
                        {
                                return variant.ToDateTime(year, month, day, 
hour, minute,
                                                                                
  second, millisecond, era);
                        }

}; // class ThaiBuddhistCalendar

}; // namespace System.Globalization





reply via email to

[Prev in Thread] Current Thread [Next in Thread]