コード例 #1
0
 internal ZonedDateTimeParseBucket(ZonedDateTime templateValue, ZoneLocalMappingResolver resolver, IDateTimeZoneProvider zoneProvider)
 {
     Date              = new LocalDatePatternParser.LocalDateParseBucket(templateValue.Date);
     Time              = new LocalTimePatternParser.LocalTimeParseBucket(templateValue.TimeOfDay);
     Zone              = templateValue.Zone;
     this.resolver     = resolver;
     this.zoneProvider = zoneProvider;
 }
コード例 #2
0
 internal ZonedDateTimeParseBucket(LocalDate templateDate, LocalTime templateTime,
                                   DateTimeZone templateZone, ZoneLocalMappingResolver resolver, IDateTimeZoneProvider zoneProvider)
 {
     Date              = new LocalDatePatternParser.LocalDateParseBucket(templateDate);
     Time              = new LocalTimePatternParser.LocalTimeParseBucket(templateTime);
     Zone              = templateZone;
     this.resolver     = resolver;
     this.zoneProvider = zoneProvider;
 }
コード例 #3
0
            /// <summary>
            /// Combines the values in a date bucket with the values in a time bucket.
            /// </summary>
            /// <remarks>
            /// This would normally be the <see cref="CalculateValue"/> method, but we want
            /// to be able to use the same logic when parsing an <see cref="OffsetDateTime"/>
            /// and <see cref="ZonedDateTime"/>.
            /// </remarks>
            internal static ParseResult <LocalDateTime> CombineBuckets(
                PatternFields usedFields,
                LocalDatePatternParser.LocalDateParseBucket dateBucket,
                LocalTimePatternParser.LocalTimeParseBucket timeBucket,
                string text)
            {
                // Handle special case of hour = 24
                bool hour24 = false;

                if (timeBucket.Hours24 == 24)
                {
                    timeBucket.Hours24 = 0;
                    hour24             = true;
                }

                ParseResult <LocalDate> dateResult = dateBucket.CalculateValue(usedFields & PatternFields.AllDateFields, text);

                if (!dateResult.Success)
                {
                    return(dateResult.ConvertError <LocalDateTime>());
                }
                ParseResult <LocalTime> timeResult = timeBucket.CalculateValue(usedFields & PatternFields.AllTimeFields, text);

                if (!timeResult.Success)
                {
                    return(timeResult.ConvertError <LocalDateTime>());
                }

                LocalDate date = dateResult.Value;
                LocalTime time = timeResult.Value;

                if (hour24)
                {
                    if (time != LocalTime.Midnight)
                    {
                        return(ParseResult <LocalDateTime> .InvalidHour24(text));
                    }
                    date = date.PlusDays(1);
                }
                return(ParseResult <LocalDateTime> .ForValue(date + time));
            }
コード例 #4
0
 internal OffsetDateTimeParseBucket(OffsetDateTime templateValue)
 {
     Date   = new LocalDatePatternParser.LocalDateParseBucket(templateValue.Date);
     Time   = new LocalTimePatternParser.LocalTimeParseBucket(templateValue.TimeOfDay);
     Offset = templateValue.Offset;
 }
コード例 #5
0
 internal LocalDateTimeParseBucket(LocalDate templateValueDate, LocalTime templateValueTime)
 {
     Date = new LocalDatePatternParser.LocalDateParseBucket(templateValueDate);
     Time = new LocalTimePatternParser.LocalTimeParseBucket(templateValueTime);
 }
コード例 #6
0
 internal OffsetDateTimeParseBucket(LocalDate templateDate, LocalTime templateTime, Offset templateOffset)
 {
     Date   = new LocalDatePatternParser.LocalDateParseBucket(templateDate);
     Time   = new LocalTimePatternParser.LocalTimeParseBucket(templateTime);
     Offset = templateOffset;
 }
コード例 #7
0
 internal OffsetDateParseBucket(OffsetDate templateValue)
 {
     Date   = new LocalDatePatternParser.LocalDateParseBucket(templateValue.Date);
     Offset = templateValue.Offset;
 }