예제 #1
0
 private static FieldSet CreatePreciseFields()
 {
     // First create the simple durations, then fill in date/time fields,
     // which rely on the other properties
     FieldSet.Builder builder = new FieldSet.Builder
                                {
                                    Ticks = TicksDurationField.Instance,
                                    Milliseconds = PreciseDurationField.Milliseconds,
                                    Seconds = PreciseDurationField.Seconds,
                                    Minutes = PreciseDurationField.Minutes,
                                    Hours = PreciseDurationField.Hours,
                                    HalfDays = PreciseDurationField.HalfDays,
                                    Days = PreciseDurationField.Days,
                                    Weeks = PreciseDurationField.Weeks
                                };
     builder.TickOfSecond = new PreciseDateTimeField(DateTimeFieldType.TickOfSecond, builder.Ticks, builder.Seconds);
     builder.TickOfMillisecond = new PreciseDateTimeField(DateTimeFieldType.TickOfMillisecond, builder.Ticks, builder.Milliseconds);
     builder.TickOfDay = new PreciseDateTimeField(DateTimeFieldType.TickOfDay, builder.Ticks, builder.Days);
     builder.MillisecondOfSecond = new PreciseDateTimeField(DateTimeFieldType.MillisecondOfSecond, builder.Milliseconds, builder.Seconds);
     builder.MillisecondOfDay = new PreciseDateTimeField(DateTimeFieldType.MillisecondOfDay, builder.Milliseconds, builder.Days);
     builder.SecondOfMinute = new PreciseDateTimeField(DateTimeFieldType.SecondOfMinute, builder.Seconds, builder.Minutes);
     builder.SecondOfDay = new PreciseDateTimeField(DateTimeFieldType.SecondOfDay, builder.Seconds, builder.Days);
     builder.MinuteOfHour = new PreciseDateTimeField(DateTimeFieldType.MinuteOfHour, builder.Minutes, builder.Hours);
     builder.MinuteOfDay = new PreciseDateTimeField(DateTimeFieldType.MinuteOfDay, builder.Minutes, builder.Days);
     builder.HourOfDay = new PreciseDateTimeField(DateTimeFieldType.HourOfDay, builder.Hours, builder.Days);
     builder.HourOfHalfDay = new PreciseDateTimeField(DateTimeFieldType.HourOfHalfDay, builder.Hours, builder.HalfDays);
     builder.ClockHourOfDay = new ZeroIsMaxDateTimeField(builder.HourOfDay, DateTimeFieldType.ClockHourOfDay);
     builder.ClockHourOfHalfDay = new ZeroIsMaxDateTimeField(builder.HourOfHalfDay, DateTimeFieldType.ClockHourOfHalfDay);
     // TODO: This was a separate subclass in Joda, for i18n purposes
     builder.HalfDayOfDay = new PreciseDateTimeField(DateTimeFieldType.HalfDayOfDay, builder.HalfDays, builder.Days);
     return builder.Build();
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalendarSystem"/> class.
 /// </summary>
 /// <param name="name">The name of the calendar</param>
 /// <param name="fieldAssembler">Delegate to invoke in order to assemble fields for this calendar.</param>
 /// <param name="eras">The eras within this calendar, which need not be unique to the calendar.</param>
 internal CalendarSystem(string name, FieldAssembler fieldAssembler, IEnumerable<Era> eras)
 {
     this.name = name;
     this.eras = new List<Era>(eras).AsReadOnly();
     FieldSet.Builder builder = new FieldSet.Builder();
     fieldAssembler(builder, this);
     this.fields = builder.Build();
 }