fixed_from_dmy() public static method

The method returns the fixed day number of the given Gregorian date.
public static fixed_from_dmy ( int day, int month, int year ) : int
day int An integer representing the day of the month, /// counting from 1. ///
month int An integer representing the month in the /// Gregorian year. ///
year int An integer representing the Gregorian year. /// Non-positive values are allowed also. ///
return int
Beispiel #1
0
        public static int GetDaysInYear(int year)
        {
            int num  = CCGregorianCalendar.fixed_from_dmy(1, 1, year);
            int num2 = CCGregorianCalendar.fixed_from_dmy(1, 1, year + 1);

            return(num2 - num);
        }
Beispiel #2
0
        public static int GetDaysInMonth(int year, int month)
        {
            int num  = CCGregorianCalendar.fixed_from_dmy(1, month, year);
            int num2 = CCGregorianCalendar.fixed_from_dmy(1, month + 1, year);

            return(num2 - num);
        }
 static JapaneseCalendar()
 {
     JapaneseCalendar.M_EraHandler = new CCGregorianEraHandler();
     JapaneseCalendar.M_EraHandler.appendEra(1, CCGregorianCalendar.fixed_from_dmy(8, 9, 1868), CCGregorianCalendar.fixed_from_dmy(29, 7, 1912));
     JapaneseCalendar.M_EraHandler.appendEra(2, CCGregorianCalendar.fixed_from_dmy(30, 7, 1912), CCGregorianCalendar.fixed_from_dmy(24, 12, 1926));
     JapaneseCalendar.M_EraHandler.appendEra(3, CCGregorianCalendar.fixed_from_dmy(25, 12, 1926), CCGregorianCalendar.fixed_from_dmy(7, 1, 1989));
     JapaneseCalendar.M_EraHandler.appendEra(4, CCGregorianCalendar.fixed_from_dmy(8, 1, 1989));
 }
Beispiel #4
0
        public static int GetDayOfYear(DateTime time)
        {
            int num  = CCFixed.FromDateTime(time);
            int year = CCGregorianCalendar.year_from_fixed(num);
            int num2 = CCGregorianCalendar.fixed_from_dmy(1, 1, year);

            return(num - num2 + 1);
        }
Beispiel #5
0
 static JapaneseLunisolarCalendar()
 {
     era_handler = new CCEastAsianLunisolarEraHandler();
     // I keep using Gregorian here, just to make them consistent
     // with JapaneseCalendar.
     era_handler.appendEra(3,
                           CCGregorianCalendar.fixed_from_dmy(25, 12, 1926),
                           CCGregorianCalendar.fixed_from_dmy(7, 1, 1989));
     era_handler.appendEra(4,
                           CCGregorianCalendar.fixed_from_dmy(8, 1, 1989));
 }
Beispiel #6
0
        public static DateTime AddYears(DateTime time, int years)
        {
            int date = CCFixed.FromDateTime(time);
            int num;
            int month;
            int num2;

            CCGregorianCalendar.dmy_from_fixed(out num, out month, out num2, date);
            num2 += years;
            int daysInMonth = CCGregorianCalendar.GetDaysInMonth(num2, month);

            if (num > daysInMonth)
            {
                num = daysInMonth;
            }
            date = CCGregorianCalendar.fixed_from_dmy(num, month, num2);
            return(CCFixed.ToDateTime(date).Add(time.TimeOfDay));
        }
Beispiel #7
0
        public static DateTime AddMonths(DateTime time, int months)
        {
            int date = CCFixed.FromDateTime(time);
            int num;
            int num2;
            int num3;

            CCGregorianCalendar.dmy_from_fixed(out num, out num2, out num3, date);
            num2 += months;
            num3 += CCMath.div_mod(out num2, num2, 12);
            int daysInMonth = CCGregorianCalendar.GetDaysInMonth(num3, num2);

            if (num > daysInMonth)
            {
                num = daysInMonth;
            }
            date = CCGregorianCalendar.fixed_from_dmy(num, num2, num3);
            return(CCFixed.ToDateTime(date).Add(time.TimeOfDay));
        }
Beispiel #8
0
        public static void my_from_fixed(out int month, out int year, int date)
        {
            year = CCGregorianCalendar.year_from_fixed(date);
            int num = date - CCGregorianCalendar.fixed_from_dmy(1, 1, year);
            int num2;

            if (date < CCGregorianCalendar.fixed_from_dmy(1, 3, year))
            {
                num2 = 0;
            }
            else if (CCGregorianCalendar.is_leap_year(year))
            {
                num2 = 1;
            }
            else
            {
                num2 = 2;
            }
            month = CCMath.div(12 * (num + num2) + 373, 367);
        }
Beispiel #9
0
 static KoreanCalendar()
 {
     KoreanCalendar.M_EraHandler = new CCGregorianEraHandler();
     KoreanCalendar.M_EraHandler.appendEra(1, CCGregorianCalendar.fixed_from_dmy(1, 1, -2332));
 }
 static JapaneseLunisolarCalendar()
 {
     JapaneseLunisolarCalendar.era_handler = new CCEastAsianLunisolarEraHandler();
     JapaneseLunisolarCalendar.era_handler.appendEra(3, CCGregorianCalendar.fixed_from_dmy(25, 12, 1926), CCGregorianCalendar.fixed_from_dmy(7, 1, 1989));
     JapaneseLunisolarCalendar.era_handler.appendEra(4, CCGregorianCalendar.fixed_from_dmy(8, 1, 1989));
 }
 static TaiwanCalendar()
 {
     TaiwanCalendar.M_EraHandler = new CCGregorianEraHandler();
     TaiwanCalendar.M_EraHandler.appendEra(1, CCGregorianCalendar.fixed_from_dmy(1, 1, 1912));
 }
 static ThaiBuddhistCalendar()
 {
     ThaiBuddhistCalendar.M_EraHandler = new CCGregorianEraHandler();
     ThaiBuddhistCalendar.M_EraHandler.appendEra(1, CCGregorianCalendar.fixed_from_dmy(1, 1, -542));
 }
Beispiel #13
0
 public static int date_difference(int dayA, int monthA, int yearA, int dayB, int monthB, int yearB)
 {
     return(CCGregorianCalendar.fixed_from_dmy(dayB, monthB, yearB) - CCGregorianCalendar.fixed_from_dmy(dayA, monthA, yearA));
 }
Beispiel #14
0
 public static void dmy_from_fixed(out int day, out int month, out int year, int date)
 {
     CCGregorianCalendar.my_from_fixed(out month, out year, date);
     day = date - CCGregorianCalendar.fixed_from_dmy(1, month, year) + 1;
 }
Beispiel #15
0
 public static DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int milliseconds)
 {
     return(CCFixed.ToDateTime(CCGregorianCalendar.fixed_from_dmy(day, month, year), hour, minute, second, (double)milliseconds));
 }