示例#1
0
        private string FormatName(ZoneLine zone)
        {
            string nameFormat = zone.Format;
            int    index      = nameFormat.IndexOf("/", StringComparison.Ordinal);

            if (index > 0)
            {
                return(recurrence.Savings == Offset.Zero ? nameFormat.Substring(0, index) : nameFormat.Substring(index + 1));
            }
            index = nameFormat.IndexOf("%s", StringComparison.Ordinal);
            if (index >= 0)
            {
                var left  = nameFormat.Substring(0, index);
                var right = nameFormat.Substring(index + 2);
                return(left + daylightSavingsIndicator + right);
            }
            index = nameFormat.IndexOf("%z", StringComparison.Ordinal);
            if (index >= 0)
            {
                var wallOffset = zone.StandardOffset + recurrence.Savings;
                var left       = nameFormat.Substring(0, index);
                var right      = nameFormat.Substring(index + 2);
                return(left + PercentZPattern.Format(wallOffset) + right);
            }
            return(nameFormat);
        }
示例#2
0
        private static void DumpZone(DateTimeZone zone, TextWriter output, int fromYear, int toYear)
        {
            output.WriteLine(zone.Id);
            var start = Instant.FromUtc(fromYear, 1, 1, 0, 0);
            // Exclusive upper bound
            var end = Instant.FromUtc(toYear + 1, 1, 1, 0, 0);

            foreach (var interval in zone.GetZoneIntervals(start, end))
            {
                output.WriteLine("{0}  {1}  {2}",
                                 DateTimePattern.Format(Instant.Max(start, interval.Start)),
                                 OffsetPattern.Format(interval.StandardOffset),
                                 OffsetPattern.Format(interval.Savings));
            }

            output.WriteLine();
        }
示例#3
0
        /// <inheritdoc />
        public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            var offset = (Offset)value;

            return(OffsetPattern.Format(offset));
        }
示例#4
0
        internal string FormatName(Offset savings, string daylightSavingsIndicator)
        {
            int index = Format.IndexOf("/", StringComparison.Ordinal);

            if (index >= 0)
            {
                return(savings == Offset.Zero ? Format.Substring(0, index) : Format.Substring(index + 1));
            }
            index = Format.IndexOf("%s", StringComparison.Ordinal);
            if (index >= 0)
            {
                var left  = Format.Substring(0, index);
                var right = Format.Substring(index + 2);
                return(left + daylightSavingsIndicator + right);
            }
            index = Format.IndexOf("%z", StringComparison.Ordinal);
            if (index >= 0)
            {
                var left  = Format.Substring(0, index);
                var right = Format.Substring(index + 2);
                return(left + PercentZPattern.Format(StandardOffset + savings) + right);
            }
            return(Format);
        }