/// <summary>
        /// Returns a <see cref="ZonedDateTime"/> parsed from the given (ISO-8601) string.
        /// </summary>
        /// <param name="value">The string value.</param>
        /// <returns>A <see cref="ZonedDateTime"/>.</returns>
        public static ZonedDateTime ToZonedDateTimeFromIso(this string value)
        {
            Condition.NotEmptyOrWhiteSpace(value, nameof(value));

            // Ensure format
            value = value
                    .Replace(" ", "T")
                    .Replace("Z", string.Empty);

            return(NodaIsoStringParsePattern.Parse(value).Value);
        }
        public static Variable DateTimeVal(string input)
        {
            if (input.Contains('@'))
            {
                var zoneDt = _zoneDtPattern.Parse(input).Value;
                return(zoneDt);
            }

            var ofstDt = OffsetDateTimePattern.Rfc3339.Parse(input);

            if (ofstDt.Success)
            {
                return(ofstDt.Value);
            }

            var localDt = LocalDateTimePattern.ExtendedIso.Parse(input);

            if (localDt.Success)
            {
                return(localDt.Value);
            }

            var ldt = LocalDatePattern.Iso.Parse(input);

            if (ldt.Success)
            {
                return(new LocalDateTime(ldt.Value.Year, ldt.Value.Month, ldt.Value.Day, 0, 0));
            }

            throw new FEELException($"Failed parsing date time string: {input}");
        }
Exemple #3
0
        public object FromEntry(DynamoDBEntry entry)
        {
            if (entry is DynamoDBNull)
            {
                return(new ZonedDateTime?());
            }
            var s   = entry.AsString();
            var res = pattern.Parse(s);

            return(res.GetValueOrThrow());
        }
Exemple #4
0
    static void ParseApple(string text)
    {
        Console.WriteLine($"Parsing {text}");
        ParseResult <ZonedDateTime> result = ApplePattern.Parse(text);

        if (!result.Success)
        {
            Console.WriteLine($"Parse failed! {result.Exception.Message}");
            return;
        }
        ZonedDateTime zonedValue = result.Value;

        Console.WriteLine($"ZonedDateTime: {zonedValue}");
        // OffsetDateTime is a Noda Time type...
        OffsetDateTime offsetValue = zonedValue.ToOffsetDateTime();

        Console.WriteLine($"OffsetDateTime: {offsetValue}");
        // DateTimeOffset is the BCL type...
        DateTimeOffset dto = offsetValue.ToDateTimeOffset();

        Console.WriteLine($"DateTimeOffset: {dto}");
        Console.WriteLine();
    }
            DateTimeZoneProviders.Tzdb);    // Won't actually be used...

    static ZonedDateTime GetZonedDateTimeUtcFromMarketDataString(string dateTime)
    => ParsePattern.Parse(dateTime).Value;
Exemple #6
0
 /// <summary>
 /// Returns the date time parsed from the given string.
 /// </summary>
 /// <param name="dateTime">The date time.</param>
 /// <returns>The converted <see cref="ZonedDateTime"/>.</returns>
 public static ZonedDateTime ParseTimestamp(string dateTime) =>
 TimestampParsePattern.Parse(dateTime).Value;