CesiumLanguageWriter.Advanced.CesiumFormattingHelper.ToIso8601 C# (CSharp) Method

ToIso8601() public static method

Converts a JulianDate to an ISO8601 date string.
public static ToIso8601 ( JulianDate date, Iso8601Format format ) : string
date JulianDate The date to convert.
format Iso8601Format The format to use.
return string
        public static string ToIso8601(JulianDate date, Iso8601Format format)
        {
            //If the JulianDate is outside the range of supported CZML values,
            //clamp it to the minimum/maximum CZML ISO8601 value.
            if (date <= s_minimumDate)
            {
                return GregorianDate.MinValue.ToIso8601String(format);
            }

            if (date >= s_maximumDate)
            {
                return GregorianDate.MaxValue.ToIso8601String(format);
            }

            return date.ToGregorianDate().ToIso8601String(format);
        }

Usage Example

Example #1
0
 /// <summary>
 /// Gets an appropriate epoch from a list of dates and writes it to the <see cref="CesiumOutputStream"/>
 /// as the "epoch" property.  If the <paramref name="dates"/> collection is empty, the <paramref name="startIndex"/>
 /// is past the end of the collection, or the <paramref name="length"/> is zero, this method does not write
 /// the "epoch" property and returns <see cref="JulianDate.MinValue"/>.
 /// </summary>
 /// <param name="output">The stream to which to write the epoch.</param>
 /// <param name="dates">The collection of dates from which to determine the epoch.</param>
 /// <param name="startIndex">The first index in the collection to use.</param>
 /// <param name="length">The number of items from the collection to use.</param>
 /// <returns>A suitable epoch determined from the collection.</returns>
 private static JulianDate GetAndWriteEpoch(CesiumOutputStream output, IList <JulianDate> dates, int startIndex, int length)
 {
     if (startIndex < dates.Count)
     {
         JulianDate epoch = dates[startIndex];
         output.WritePropertyName("epoch");
         output.WriteValue(CesiumFormattingHelper.ToIso8601(epoch, output.PrettyFormatting ? Iso8601Format.Extended : Iso8601Format.Compact));
         return(epoch);
     }
     else
     {
         return(JulianDate.MinValue);
     }
 }
All Usage Examples Of CesiumLanguageWriter.Advanced.CesiumFormattingHelper::ToIso8601