⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timezoneadjustmentfield.cs

📁 pureIRCd是一个用c语音写的irc(RFC459)服务,可以给您带来很多的方便
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace SDP
{
    /// <summary>
    /// This represents the z= field of RFC 2327. From RFC 2327:
    /// 
    /// To schedule a repeated session which spans a change from daylight-
    /// saving time to standard time or vice-versa, it is necessary to
    /// specify offsets from the base repeat times. This is required
    /// because different time zones change time at different times of day,
    /// different countries change to or from daylight time on different
    /// dates, and some countries do not have daylight saving time at all.
    /// 
    /// Thus in order to schedule a session that is at the same time winter
    /// and summer, it must be possible to specify unambiguously by whose
    /// time zone a session is scheduled.  To simplify this task for
    /// receivers, we allow the sender to specify the NTP time that a time
    /// zone adjustment happens and the offset from the time when the
    /// session was first scheduled.  The "z" field allows the sender to
    /// specify a list of these adjustment times and offsets from the base time.
    /// 
    /// An example might be:
    /// 
    ///     z=2882844526 -1h 2898848070 0
    /// 
    /// This specifies that at time 2882844526 the time base by which the
    /// session's repeat times are calculated is shifted back by 1 hour,
    /// and that at time 2898848070 the session's original time base is
    /// restored. Adjustments are always relative to the specified start
    /// time - they are not cumulative.
    /// </summary>
    public class TimeZoneAdjustmentField : Field
    {
        private List<TimeZoneAdjustment> zoneAdjustments;
        /// <summary>
        /// Gets a list of TimeZoneAdjustments.
        /// </summary>
        public List<TimeZoneAdjustment> ZoneAdjustments
        {
            get { return this.zoneAdjustments; }
        }

        /// <summary>
        /// Creates a new TimeZoneAdjustmentField.
        /// </summary>
        /// <param name="value">The value portion of the field.</param>
        public TimeZoneAdjustmentField(string value)
            : base("z=" + value)
        {
            string val = base.Value;
            string[] parts = val.Split(' ');
            if (parts.Length % 2 != 0) throw new ArgumentException();
            this.zoneAdjustments = new List<TimeZoneAdjustment>();
            for (int i = 0; i < parts.Length - 1; i += 2)
            {
                this.zoneAdjustments.Add(new TimeZoneAdjustment(parts[i] + " " + parts[i + 1]));
            }
        }

        /// <summary>
        /// Gets the value portion of the field.
        /// </summary>
        public override string Value
        {
            get
            {
                string s = "";
                foreach (TimeZoneAdjustment t in this.zoneAdjustments)
                {
                    s = s + t.ToString() + " ";
                }
                return s.Trim();
            }
        }

        /// <summary>
        /// Converts this TimeZoneAdjustmentField to it's string representation.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "z=" + this.Value + "\r\n";
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -