Пример #1
0
 public static TimeDefinition valueOf(string name)
 {
     foreach (TimeDefinition enumInstance in TimeDefinition.values())
     {
         if (enumInstance.nameValue == name)
         {
             return(enumInstance);
         }
     }
     throw new System.ArgumentException(name);
 }
Пример #2
0
 /// <summary>
 /// Creates an instance defining the yearly rule to create transitions between two offsets.
 /// </summary>
 /// <param name="month">  the month of the month-day of the first day of the cutover week, not null </param>
 /// <param name="dayOfMonthIndicator">  the day of the month-day of the cutover week, positive if the week is that
 ///  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 ///  from -28 to 31 excluding 0 </param>
 /// <param name="dayOfWeek">  the required day-of-week, null if the month-day should not be changed </param>
 /// <param name="time">  the cutover time in the 'before' offset, not null </param>
 /// <param name="timeEndOfDay">  whether the time is midnight at the end of day </param>
 /// <param name="timeDefnition">  how to interpret the cutover </param>
 /// <param name="standardOffset">  the standard offset in force at the cutover, not null </param>
 /// <param name="offsetBefore">  the offset before the cutover, not null </param>
 /// <param name="offsetAfter">  the offset after the cutover, not null </param>
 /// <exception cref="IllegalArgumentException"> if the day of month indicator is invalid </exception>
 /// <exception cref="IllegalArgumentException"> if the end of day flag is true when the time is not midnight </exception>
 internal ZoneOffsetTransitionRule(Month month, int dayOfMonthIndicator, DayOfWeek dayOfWeek, LocalTime time, bool timeEndOfDay, TimeDefinition timeDefnition, ZoneOffset standardOffset, ZoneOffset offsetBefore, ZoneOffset offsetAfter)
 {
     this.Month_Renamed          = month;
     this.Dom                    = (sbyte)dayOfMonthIndicator;
     this.Dow                    = dayOfWeek;
     this.Time                   = time;
     this.TimeEndOfDay           = timeEndOfDay;
     this.TimeDefinition_Renamed = timeDefnition;
     this.StandardOffset_Renamed = standardOffset;
     this.OffsetBefore_Renamed   = offsetBefore;
     this.OffsetAfter_Renamed    = offsetAfter;
 }
Пример #3
0
        /// <summary>
        /// Reads the state from the stream.
        /// </summary>
        /// <param name="in">  the input stream, not null </param>
        /// <returns> the created object, not null </returns>
        /// <exception cref="IOException"> if an error occurs </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static ZoneOffsetTransitionRule readExternal(java.io.DataInput in) throws java.io.IOException
        internal static ZoneOffsetTransitionRule ReadExternal(DataInput @in)
        {
            int            data       = @in.ReadInt();
            Month          month      = Month.of((int)((uint)data >> 28));
            int            dom        = ((int)((uint)(data & (63 << 22)) >> 22)) - 32;
            int            dowByte    = (int)((uint)(data & (7 << 19)) >> 19);
            DayOfWeek      dow        = dowByte == 0 ? null : DayOfWeek.of(dowByte);
            int            timeByte   = (int)((uint)(data & (31 << 14)) >> 14);
            TimeDefinition defn       = TimeDefinition.values()[(int)((uint)(data & (3 << 12)) >> 12)];
            int            stdByte    = (int)((uint)(data & (255 << 4)) >> 4);
            int            beforeByte = (int)((uint)(data & (3 << 2)) >> 2);
            int            afterByte  = (data & 3);
            LocalTime      time       = (timeByte == 31 ? LocalTime.OfSecondOfDay(@in.ReadInt()) : LocalTime.Of(timeByte % 24, 0));
            ZoneOffset     std        = (stdByte == 255 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds((stdByte - 128) * 900));
            ZoneOffset     before     = (beforeByte == 3 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds(std.TotalSeconds + beforeByte * 1800));
            ZoneOffset     after      = (afterByte == 3 ? ZoneOffset.OfTotalSeconds(@in.ReadInt()) : ZoneOffset.OfTotalSeconds(std.TotalSeconds + afterByte * 1800));

            return(ZoneOffsetTransitionRule.Of(month, dom, dow, time, timeByte == 24, defn, std, before, after));
        }
Пример #4
0
 /// <summary>
 /// Obtains an instance defining the yearly rule to create transitions between two offsets.
 /// <para>
 /// Applications should normally obtain an instance from <seealso cref="ZoneRules"/>.
 /// This factory is only intended for use when creating <seealso cref="ZoneRules"/>.
 ///
 /// </para>
 /// </summary>
 /// <param name="month">  the month of the month-day of the first day of the cutover week, not null </param>
 /// <param name="dayOfMonthIndicator">  the day of the month-day of the cutover week, positive if the week is that
 ///  day or later, negative if the week is that day or earlier, counting from the last day of the month,
 ///  from -28 to 31 excluding 0 </param>
 /// <param name="dayOfWeek">  the required day-of-week, null if the month-day should not be changed </param>
 /// <param name="time">  the cutover time in the 'before' offset, not null </param>
 /// <param name="timeEndOfDay">  whether the time is midnight at the end of day </param>
 /// <param name="timeDefnition">  how to interpret the cutover </param>
 /// <param name="standardOffset">  the standard offset in force at the cutover, not null </param>
 /// <param name="offsetBefore">  the offset before the cutover, not null </param>
 /// <param name="offsetAfter">  the offset after the cutover, not null </param>
 /// <returns> the rule, not null </returns>
 /// <exception cref="IllegalArgumentException"> if the day of month indicator is invalid </exception>
 /// <exception cref="IllegalArgumentException"> if the end of day flag is true when the time is not midnight </exception>
 public static ZoneOffsetTransitionRule Of(Month month, int dayOfMonthIndicator, DayOfWeek dayOfWeek, LocalTime time, bool timeEndOfDay, TimeDefinition timeDefnition, ZoneOffset standardOffset, ZoneOffset offsetBefore, ZoneOffset offsetAfter)
 {
     Objects.RequireNonNull(month, "month");
     Objects.RequireNonNull(time, "time");
     Objects.RequireNonNull(timeDefnition, "timeDefnition");
     Objects.RequireNonNull(standardOffset, "standardOffset");
     Objects.RequireNonNull(offsetBefore, "offsetBefore");
     Objects.RequireNonNull(offsetAfter, "offsetAfter");
     if (dayOfMonthIndicator < -28 || dayOfMonthIndicator > 31 || dayOfMonthIndicator == 0)
     {
         throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
     }
     if (timeEndOfDay && time.Equals(LocalTime.MIDNIGHT) == false)
     {
         throw new IllegalArgumentException("Time must be midnight when end of day flag is true");
     }
     return(new ZoneOffsetTransitionRule(month, dayOfMonthIndicator, dayOfWeek, time, timeEndOfDay, timeDefnition, standardOffset, offsetBefore, offsetAfter));
 }