コード例 #1
0
        public static NSCalendarUnit ToNSCalendarUnit(this Periodo periodo)
        {
            NSCalendarUnit iosUnit = NSCalendarUnit.Month;

            switch (periodo)
            {
            case Periodo.Hora:
                iosUnit = NSCalendarUnit.Hour;
                break;

            case Periodo.Dia:
                iosUnit = NSCalendarUnit.Day;
                break;

            case Periodo.Semana:
                iosUnit = NSCalendarUnit.Week;
                break;

            case Periodo.Mes:
                iosUnit = NSCalendarUnit.Month;
                break;

            default:
                break;
            }

            return(iosUnit);
        }
コード例 #2
0
        public void TestOrdinality(int year, int month, int day, NSCalendarUnit smaller, NSCalendarUnit larger, int expected)
        {
            var cal        = new NSCalendar(NSCalendarType.Gregorian);
            var date       = new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Local);
            var ordinality = cal.Ordinality(smaller, larger, (NSDate)date);

            Assert.AreEqual(ordinality, expected);
        }
コード例 #3
0
        public void TestMaximumRange(int location, int length, NSCalendarUnit unit)
        {
            var cal   = new NSCalendar(NSCalendarType.Gregorian);
            var range = cal.MaximumRange(unit);

            Assert.AreEqual(length, range.Length);
            Assert.AreEqual(location, range.Location);
        }
コード例 #4
0
        public void TestOrdinality(int year, int month, int day, NSCalendarUnit smaller, NSCalendarUnit larger, int expected)
        {
            var cal  = new NSCalendar(NSCalendarType.Gregorian);
            var date = new DateTime(year, month, day, 0, 0, 0, DateTimeKind.Utc);
            var dt   = (NSDate)date;

            cal.TimeZone = NSTimeZone.FromName("Europe/Madrid");
            Assert.AreEqual((nuint)expected, cal.Ordinality(smaller, larger, dt), $"Ordinality");
        }
コード例 #5
0
        public void TestRangeOrUnitIntervalNotNull(int year, int month, int day, NSCalendarUnit unit, double expectedInterval)
        {
            var cal  = new NSCalendar(NSCalendarType.Gregorian);
            var date = new DateTime(year, month, day);

            date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
            var    outDate = (NSDate)DateTime.Now;
            double outInterval;
            var    success = cal.Range(unit, out outDate, out outInterval, (NSDate)date);

            Assert.AreEqual(expectedInterval, outInterval);
        }
コード例 #6
0
 public override void ScheduleLocalNotification(NotificationData notification, SchedulingData schedule)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(delegate {
         if (notification != null)
         {
             UILocalNotification localNotification = this.PrepareLocalNotification(notification);
             if (schedule != null)
             {
                 localNotification.FireDate = IPhoneUtils.DateTimeToNSDate(DateTime.SpecifyKind(schedule.FireDate, DateTimeKind.Local));
                 SystemLogger.Log(SystemLogger.Module.PLATFORM, "Scheduling local notification at "
                                  + schedule.FireDate.ToLongTimeString() + ", with a repeat interval of: " + schedule.RepeatInterval);
                 NSCalendarUnit repeatInterval = 0;                         // The default value is 0, which means don't repeat.
                 if (schedule.RepeatInterval.Equals(RepeatInterval.HOURLY))
                 {
                     repeatInterval = NSCalendarUnit.Hour;
                 }
                 else if (schedule.RepeatInterval.Equals(RepeatInterval.DAILY))
                 {
                     repeatInterval = NSCalendarUnit.Day;
                 }
                 else if (schedule.RepeatInterval.Equals(RepeatInterval.WEEKLY))
                 {
                     repeatInterval = NSCalendarUnit.Week;
                 }
                 else if (schedule.RepeatInterval.Equals(RepeatInterval.MONTHLY))
                 {
                     repeatInterval = NSCalendarUnit.Month;
                 }
                 else if (schedule.RepeatInterval.Equals(RepeatInterval.YEARLY))
                 {
                     repeatInterval = NSCalendarUnit.Year;
                 }
                 localNotification.RepeatInterval = repeatInterval;
                 UIApplication.SharedApplication.ScheduleLocalNotification(localNotification);
                 SystemLogger.Log(SystemLogger.Module.PLATFORM, "Local Notification scheduled successfully [" + localNotification.FireDate.ToString() + "]");
                 SystemLogger.Log(SystemLogger.Module.PLATFORM, "Current scheduled #num of local notifications: " + this.GetCurrentScheduledLocalNotifications());
             }
             else
             {
                 SystemLogger.Log(SystemLogger.Module.PLATFORM, "No suitable scheduling data object received for scheduling this local notification");
             }
         }
         else
         {
             SystemLogger.Log(SystemLogger.Module.PLATFORM, "No suitable data object received for presenting local notification");
         }
     });
 }
コード例 #7
0
ファイル: Reminder_ios.cs プロジェクト: joseplj/MySkinSelfie
        private NSCalendarUnit GetCalUnit(long millis)
        {
            NSCalendarUnit unit = NSCalendarUnit.Day;
            long           day  = 1000 * 60 * 60 * 24;

            if (millis > day * 7)
            {
                unit = NSCalendarUnit.Month;
            }
            else if (millis > day)
            {
                unit = NSCalendarUnit.Week;
            }

            return(unit);
        }
コード例 #8
0
 public virtual bool RangeOfUnit(NSCalendarUnit unit, AutoreleasingUnsafeMutablePointer <NSDate> startDate, UnsafeMutablePointer <NSTimeInterval> interval, NSDate forDate)
 {
     return(default(bool));
 }
コード例 #9
0
 public virtual NSRange RangeOfUnit(NSCalendarUnit smaller, NSCalendarUnit inUnit, NSDate forDate)
 {
     return(default(NSRange));
 }
コード例 #10
0
 public virtual int OrdinalityOfUnit(NSCalendarUnit smaller, NSCalendarUnit inUnit, NSDate forDate)
 {
     return(default(int));
 }
コード例 #11
0
 public virtual NSRange MinimumRangeOfUnit(NSCalendarUnit unit)
 {
     return(default(NSRange));
 }
コード例 #12
0
 public virtual NSDateComponents Components(NSCalendarUnit unitFlags, NSDate fromDate, NSDate toDate, NSCalendarOptions options)
 {
     return(default(NSDateComponents));
 }
コード例 #13
0
        public void TestRange(int year, int month, int day, int location, int length, NSCalendarUnit smaller, NSCalendarUnit larger)
        {
            var cal  = new NSCalendar(NSCalendarType.Gregorian);
            var date = new DateTime(year, month, day);

            date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
            var range = cal.Range(smaller, larger, (NSDate)date);

            Assert.AreEqual(location, range.Location);
            Assert.AreEqual(length, range.Length);
        }