/// <summary> /// Add offset to an unspecified local time /// </summary> /// <param name="offsetHour"></param> /// <param name="offsetMinute"></param> /// <param name="offsetSign"></param> public void addOffset(int offsetHour, int offsetMinute, OffsetSign offsetSign) { if (this.reference != TimeReference.undefined) { throw new TimeHandlerException("Time offset can only be added to undefined local time!"); } this.offsetHour = offsetHour; this.offsetMinute = offsetMinute; this.offsetSign = offsetSign; this.reference = TimeReference.offset; }
/// <summary> /// Create a Local Time with a given offset to UTC /// </summary> /// <param name="hour"></param> /// <param name="minute"></param> /// <param name="second"></param> /// <param name="offsetHour"></param> /// <param name="offsetMinute"></param> /// <param name="offsetSign"></param> public CompleteTime(int hour, int minute, int second, int offsetHour, int offsetMinute, OffsetSign offsetSign) { this.hour = hour; this.minute = minute; this.second = second; this.offsetHour = offsetHour; this.offsetMinute = offsetMinute; this.offsetSign = offsetSign; this.reference = TimeReference.offset; this.validate(); }
/// <summary> /// Create using ISO 8601- string /// </summary> /// <param name="ISO8601"></param> public CompleteTime(string ISO8601) { ISO8601 = ISO8601.Replace(separator, String.Empty); this.hour = Convert.ToInt32(ISO8601.Substring(0, 2)); this.minute = Convert.ToInt32(ISO8601.Substring(2, 2)); this.second = Convert.ToInt32(ISO8601.Substring(4, 2)); if (ISO8601.Length > 6 && (ISO8601.Substring(6, 1).Equals("Z") || ISO8601.Substring(6, 1).Equals("z"))) { this.reference = TimeReference.UTC; } else if (ISO8601.Length > 6) { this.reference = TimeReference.offset; this.offsetSign = ISO8601.Substring(6, 1).Equals("+") ? OffsetSign.positive : OffsetSign.negative; this.offsetHour = Convert.ToInt32(ISO8601.Substring(7, 2)); this.offsetMinute = Convert.ToInt32(ISO8601.Substring(9, 2)); } this.validate(); }