Exemplo n.º 1
0
    public static void Main()
    {
        // Creates and initializes a HijriCalendar.
        HijriCalendar myCal = new HijriCalendar();

        // Displays the header.
        Console.Write("YEAR\t");
        for (int y = 1421; y <= 1425; y++)
        {
            Console.Write("\t{0}", y);
        }
        Console.WriteLine();

        // Displays the value of the CurrentEra property.
        Console.Write("CurrentEra:");
        for (int y = 1421; y <= 1425; y++)
        {
            Console.Write("\t{0}", myCal.GetDaysInMonth(y, 12, HijriCalendar.CurrentEra));
        }
        Console.WriteLine();

        // Displays the values in the Eras property.
        for (int i = 0; i < myCal.Eras.Length; i++)
        {
            Console.Write("Era {0}:\t", myCal.Eras[i]);
            for (int y = 1421; y <= 1425; y++)
            {
                Console.Write("\t{0}", myCal.GetDaysInMonth(y, 12, myCal.Eras[i]));
            }
            Console.WriteLine();
        }
    }
Exemplo n.º 2
0
        public async Task <List <long> > GetJobApplicationStatsFunnelGraph(int lengthOfTime, string userAccountId)
        {
            try
            {
                HijriCalendar cal = new HijriCalendar();
                List <long>   JobApplicationStats = new List <long>();
                DateTime      dateToLookFrom      = DateTime.Now;
                if (lengthOfTime == 0) // Week
                {
                    dateToLookFrom = DateTime.Now.AddDays(-7);
                }
                else if (lengthOfTime == 1)  // Month
                {
                    int daysInMonth = cal.GetDaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
                    dateToLookFrom = DateTime.Now.AddDays(daysInMonth * -1);
                }
                else if (lengthOfTime == 2) // 6 Months
                {
                    int totalDays = 0;
                    for (int i = DateTime.Now.Month; i > DateTime.Now.Month - 6; i--)
                    {
                        totalDays += cal.GetDaysInMonth(DateTime.Now.Year, i);
                    }
                    dateToLookFrom = DateTime.Now.AddDays(totalDays * -1);
                }
                else if (lengthOfTime == 3) // Year
                {
                    dateToLookFrom = DateTime.Now.AddDays(-365);
                }

                var totalJobApplications      = _jobApplications.Find(x => (x.UserAccountId == userAccountId) && (x.DateApplied >= dateToLookFrom)).CountDocumentsAsync();
                var jobApplicationsInProgress = _jobApplications.Find(x => (x.UserAccountId == userAccountId) && (x.DateApplied >= dateToLookFrom) && (x.Status == 2)).CountDocumentsAsync();
                var jobApplicationsAccepted   = _jobApplications.Find(x => (x.UserAccountId == userAccountId) && (x.DateApplied >= dateToLookFrom) && (x.Status == 4)).CountDocumentsAsync();
                JobApplicationStats.Add(await totalJobApplications);
                JobApplicationStats.Add(await jobApplicationsInProgress);
                JobApplicationStats.Add(await jobApplicationsAccepted);
                return(JobApplicationStats);
            } catch
            {
                return(null);
            }
        }
Exemplo n.º 3
0
    public static void Main()
    {
        // Creates and initializes a HijriCalendar.
        HijriCalendar myCal = new HijriCalendar();

        // Creates a holder for the last day of the second month (February).
        int iLastDay;

        // Displays the header.
        Console.Write("YEAR\t");
        for (int y = 1421; y <= 1425; y++)
        {
            Console.Write("\t{0}", y);
        }
        Console.WriteLine();

        // Checks five years in the current era.
        Console.Write("CurrentEra:");
        for (int y = 1421; y <= 1425; y++)
        {
            iLastDay = myCal.GetDaysInMonth(y, 2, HijriCalendar.CurrentEra);
            Console.Write("\t{0}", myCal.IsLeapDay(y, 2, iLastDay, HijriCalendar.CurrentEra));
        }
        Console.WriteLine();

        // Checks five years in each of the eras.
        for (int i = 0; i < myCal.Eras.Length; i++)
        {
            Console.Write("Era {0}:\t", myCal.Eras[i]);
            for (int y = 1421; y <= 1425; y++)
            {
                iLastDay = myCal.GetDaysInMonth(y, 2, myCal.Eras[i]);
                Console.Write("\t{0}", myCal.IsLeapDay(y, 2, iLastDay, myCal.Eras[i]));
            }
            Console.WriteLine();
        }
    }
Exemplo n.º 4
0
		public void ObtainHijriDate(DateTime dt)
		{
			var hcal = new HijriCalendar();
			HijriEventArgs args = new HijriEventArgs();
			args.year = hcal.GetYear(dt);
			args.month = hcal.GetMonth(dt);
			args.daysInMonth = hcal.GetDaysInMonth(args.year, args.month);
			args.dayOfMonth = hcal.GetDayOfMonth(dt);

			//start date of same month in hijri
			var sdt = dt.AddDays(-args.dayOfMonth + 1);
			args.monthStartWeekDay = (int)hcal.GetDayOfWeek(sdt);

			//set hijri current year, month, & day
			args.currentYear = hcal.GetYear(DateTime.Now);
			args.currentMonth = hcal.GetMonth(DateTime.Now);
			args.currentDay = hcal.GetDayOfMonth(DateTime.Now);

			dateObtained(this, args);
		}
Exemplo n.º 5
0
 /// <summary>
 /// Gets the number of days in specified year and month of the current era.
 /// </summary>
 /// <param name="year">An integer representing the year.</param>
 /// <param name="month">An integer representing the month.</param>
 /// <returns></returns>
 public int GetDaysInMonth(int year, int month)
 {
     return(hc.GetDaysInMonth(year, month));
 }