コード例 #1
0
        /// <summary>
        /// Transforms a coordinate to date/time.
        /// </summary>
        /// <param name="coordinate">The coordinate.</param>
        /// <returns>A date/time representation of the specified coordinate in the Gregorian calendar and UTC clock.</returns>
        /// <exception cref="System.ArgumentNullException">The coordinate is null.</exception>
        /// <exception cref="System.ArgumentException">
        /// The coordinate is not referenced in the current coordinate system.
        /// or
        /// The coordinate is before the origin of the current coordinate system.
        /// </exception>
        public override DateAndTime TransformToDateAndTime(TemporalCoordinate coordinate)
        {
            if (coordinate == null)
            {
                throw new ArgumentNullException("coordinate", "The coordinate is null.");
            }
            if (!coordinate.ReferenceSystem.Equals(this))
            {
                throw new ArgumentException("The coordinate is not referenced in the current coordinate system.", "coordinate");
            }
            if (coordinate.Instant.Ticks < 0)
            {
                throw new ArgumentException("The coordinate is before the origin of the current coordinate system.", "coordinate");
            }

            // compute the components
            Int64 date = Convert.ToInt64((coordinate as JulianDate).Date) + Origin.Date.Instant.Ticks;
            Int64 time = Convert.ToInt64((coordinate as JulianDate).Time / Clocks.UTC.SecondsPerDay) * Clocks.UTC.TicksPerDay;

            // correct the half day
            if (time > Clocks.UTC.TicksPerDay / 2)
            {
                time -= Clocks.UTC.TicksPerDay / 2;
            }
            else
            {
                date--;
                time += Clocks.UTC.TicksPerDay / 2;
            }

            return(new DateAndTime(new Instant(date), new Instant(time), CompoundTemporalReferenceSystems.GregorianCalendarUTCClock, null));
        }
コード例 #2
0
        /// <summary>
        /// Transforms a coordinate to date/time.
        /// </summary>
        /// <param name="coordinate">The coordinate.</param>
        /// <returns>A date/time representation of the specified coordinate in the Gregorian calendar and UTC clock.</returns>
        /// <exception cref="System.ArgumentNullException">The coordinate is null.</exception>
        /// <exception cref="System.ArgumentException">
        /// The coordinate is not referenced in the current coordinate system.
        /// or
        /// The coordinate is before the origin of the current coordinate system.
        /// </exception>
        public override DateAndTime TransformToDateAndTime(TemporalCoordinate coordinate)
        {
            if (coordinate == null)
            {
                throw new ArgumentNullException("coordinate", "The coordinate is null.");
            }
            if (!coordinate.ReferenceSystem.Equals(this))
            {
                throw new ArgumentException("The coordinate is not referenced in the current coordinate system.", "coordinate");
            }

            JulianDate julianDate = new JulianDate(new Instant((coordinate as JulianDate).Instant.Ticks + 2400000 * Clocks.UTC.SecondsPerDay), TemporalCoordinateSystems.JulianDateSystem, null);

            return(base.TransformToDateAndTime(julianDate));
        }
コード例 #3
0
 /// <summary>
 /// Transforms a coordinate to date/time.
 /// </summary>
 /// <param name="coordinate">The coordinate.</param>
 /// <returns>A date/time representation of the specified coordinate in the Gregorian calendar and UTC clock.</returns>
 /// <exception cref="System.ArgumentNullException">The coordinate is null.</exception>
 /// <exception cref="System.ArgumentException">
 /// The coordinate is not referenced in the current coordinate system.
 /// or
 /// The coordinate is before the origin of the current coordinate system.
 /// </exception>
 public abstract DateAndTime TransformToDateAndTime(TemporalCoordinate coordinate);