public override Moment ToMoment(TimeSpan standardOffset, TimeSpan daylightSavingsOffset)
        {
            var dateTime = new DateTime(Date.Year, (int)Date.MonthOfYear, Date.DayOfMonth, Time.Hours, Time.Minutes,
                                        Time.Seconds, DateTimeKind.Utc);

            return(Moment.Create(dateTime));
        }
示例#2
0
        public override Moment ToMoment(TimeSpan standardOffset, TimeSpan daylightSavingsOffset)
        {
            // convert to UTC
            var dateTime = new DateTime(Date.Year, (int)Date.MonthOfYear, Date.DayOfMonth, Time.Hours, Time.Minutes,
                                        Time.Seconds, DateTimeKind.Utc);

            dateTime = dateTime.AddHours(standardOffset.Hours + daylightSavingsOffset.Hours);
            dateTime = dateTime.AddMinutes(standardOffset.Minutes + daylightSavingsOffset.Minutes);
            dateTime = dateTime.AddSeconds(standardOffset.Seconds + daylightSavingsOffset.Seconds);

            return(Moment.Create(dateTime));
        }
示例#3
0
        /// <summary>
        ///     Processes this <see cref="DaylightSavingsRule" /> for a given <paramref name="standardOffset" />,
        ///     <paramref name="daylightSavingsAdjustment" />,
        ///     and <paramref name="year" />
        /// </summary>
        /// <param name="standardOffset"></param>
        /// <param name="daylightSavingsAdjustment"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public Moment ToMoment(TimeSpan standardOffset, TimeSpan daylightSavingsAdjustment, int year)
        {
            MonthOfYear monthRuleOccurs = OccursIn;
            int         dayRuleOccurs   = OccursOnSpecification.ToDayOfMonth(year, monthRuleOccurs);

            // handle rules specified in UtcTime
            var utcTime = OccursAt as UtcTime;

            if (null != utcTime)
            {
                var dateTime = new DateTime(year, (int)monthRuleOccurs, dayRuleOccurs, OccursAt.Hours, OccursAt.Minutes,
                                            OccursAt.Seconds, DateTimeKind.Utc);
                return(Moment.Create(dateTime));
            }

            // handle rules specified in StandardTime
            var standardTime = OccursAt as StandardTime;

            if (null != standardTime)
            {
                // convert to UTC
                var dateTime = new DateTime(year, (int)monthRuleOccurs, dayRuleOccurs, OccursAt.Hours, OccursAt.Minutes,
                                            OccursAt.Seconds, DateTimeKind.Utc);
                dateTime = dateTime.AddHours(standardOffset.Hours);
                dateTime = dateTime.AddMinutes(standardOffset.Minutes);
                dateTime = dateTime.AddSeconds(standardOffset.Seconds);

                return(Moment.Create(dateTime));
            }

            // handle rules specified in LocalTime
            var localTime = OccursAt as LocalTime;

            if (null != localTime)
            {
                // convert to UTC
                var dateTime = new DateTime(year, (int)monthRuleOccurs, dayRuleOccurs, OccursAt.Hours, OccursAt.Minutes,
                                            OccursAt.Seconds, DateTimeKind.Utc);
                dateTime = dateTime.AddHours(standardOffset.Hours + daylightSavingsAdjustment.Hours);
                dateTime = dateTime.AddMinutes(standardOffset.Minutes + daylightSavingsAdjustment.Minutes);
                dateTime = dateTime.AddSeconds(standardOffset.Seconds + daylightSavingsAdjustment.Seconds);

                return(Moment.Create(dateTime));
            }

            string msg = String.Format("An exception occured while converting {0} to a {1}",
                                       typeof(DaylightSavingsRule),
                                       typeof(Moment));

            throw new Exception(msg);
        }
示例#4
0
        public Moment Get(Vector3 position)
        {
            Vector3 starLocalPosition   = _mainStar.RotationStartingVector - _planetCenter;
            Vector3 getterLocalPosition = position - _planetCenter;

            float setterStarAngle = -Vector3.SignedAngle(
                Vector3.ProjectOnPlane(starLocalPosition, _planetRotationAxis),
                Vector3.ProjectOnPlane(getterLocalPosition, _planetRotationAxis),
                _planetRotationAxis);

            setterStarAngle += 180 + _mainStar.RotationAngle;
            setterStarAngle.MakeCycleDegrees360();

            return(Moment.Create(setterStarAngle / 360));
        }
        public async Task SendMomentAsync()
        {
            var user = await AmazonWebService.Instance.GetUserAsync();

            var moment = Moment.Create(user);

            moment.Position = App.Instance.CurrentPosition;
            moment.Address  = App.Instance.CurrentAddress;
            await AmazonWebService.Instance.SaveMomentAsync(moment, image);

            user.SentMomentsCount++;
            await AmazonWebService.Instance.SaveUserAsync(user);

            await LocalDataService.Instance.SaveMomentAsync(moment, image);

            await NavigationService.Instance.ShowMomentListAsync();

            DialogService.ShowSuccess("Moment sent!");
        }