internal Note(Training training, Guid authorId, string content, NodaTime.Instant timestamp) { Guard.Against.Null(training, nameof(training)); Guard.Against.Default(authorId, nameof(authorId)); Guard.Against.NullOrWhiteSpace(content, nameof(content)); Guard.Against.Default(timestamp, nameof(timestamp)); Training = training; AuthorId = authorId; Content = content; Timestamp = timestamp; }
public void AddQuote(NodaTime.Instant date, double close, double open, double low, double high) { When(new Chronos.Core.Events.QuoteAdded(date, close, open, low, high)); }
public Result <Nothing, Error> CanSendTrainingReminder(SendTrainingReminder.Command command, Training training, NodaTime.Instant now) { Guard.Against.Null(command, nameof(command)); Guard.Against.Null(training, nameof(training)); ValidateIdMatchOrThrow(command.EnrollmentId); if (SelectedTrainingID != null && training.ID != SelectedTrainingID) { return(Result.Failure <Nothing, Error>(new Error.DomainError(SendTrainingReminder_Messages.Reminder_cannot_be_sent_if_the_candidate_is_not_invited_to_training))); } if (HasResignedEffectively(training.StartDateTime.ToInstant()) || HasResignedEffectively(now)) { return(Result.Failure <Nothing, Error>(new Error.DomainError(SendTrainingReminder_Messages.Reminder_cannot_be_sent_if_the_candidate_resigned))); } if (SelectedTrainingID == null) { return(Result.Failure <Nothing, Error>(new Error.DomainError(SendTrainingReminder_Messages.Reminder_cannot_be_sent_if_the_candidate_is_not_invited_to_training))); } if (training.StartDateTime.ToInstant().Minus(now) > Duration.FromHours(24)) { return(Result.Failure <Nothing, Error>(new Error.DomainError(SendTrainingReminder_Messages.Reminder_cannot_be_sent_earlier_than_24h_before_training))); } if (training.StartDateTime.ToInstant() < now) { return(Result.Failure <Nothing, Error>(new Error.DomainError(SendTrainingReminder_Messages.Reminder_cannot_be_sent_after_training_start))); } return(Result.Success <Nothing, Error>(Nothing.Value)); }
/// <summary> /// Initializes a new instance of the <see cref="ZonedDateTime"/> struct. /// </summary> /// <param name="instant">The instant.</param> /// <param name="zone">The time zone.</param> /// <param name="calendar">The calendar system.</param> public ZonedDateTime(Instant instant, DateTimeZone zone, CalendarSystem calendar) { this.zone = Preconditions.CheckNotNull(zone, nameof(zone)); offsetDateTime = new OffsetDateTime(instant, zone.GetUtcOffset(instant), Preconditions.CheckNotNull(calendar, nameof(calendar))); }
/// <summary> /// Initializes a new instance of the <see cref="ZonedDateTime" /> struct in the specified time zone /// and the ISO calendar. /// </summary> /// <param name="instant">The instant.</param> /// <param name="zone">The time zone.</param> public ZonedDateTime(Instant instant, DateTimeZone zone) { this.zone = Preconditions.CheckNotNull(zone, nameof(zone)); offsetDateTime = new OffsetDateTime(instant, zone.GetUtcOffset(instant)); }
/// <summary> /// Returns all the zone intervals which occur for any instant in the interval [<paramref name="start"/>, <paramref name="end"/>). /// </summary> /// <remarks> /// <para>This method is simply a convenience method for calling <see cref="GetZoneIntervals(Interval)"/> without /// explicitly constructing the interval beforehand. /// </para> /// </remarks> /// <param name="start">Inclusive start point of the interval for which to retrieve zone intervals.</param> /// <param name="end">Exclusive end point of the interval for which to retrieve zone intervals.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="end"/> is earlier than <paramref name="start"/>.</exception> /// <returns>A sequence of zone intervals covering the given interval.</returns> /// <seealso cref="DateTimeZone.GetZoneInterval"/> public IEnumerable <ZoneInterval> GetZoneIntervals(Instant start, Instant end) => // The constructor performs all the validation we need. GetZoneIntervals(new Interval(start, end));
/// <summary> /// Returns a new <see cref="ZonedDateTime"/> representing the same instant in time as the given /// <see cref="DateTimeOffset"/>. /// The time zone used will be a fixed time zone, which uses the same offset throughout time. /// </summary> /// <param name="dateTimeOffset">Date and time value with an offset.</param> /// <returns>A <see cref="ZonedDateTime"/> value representing the same instant in time as the given <see cref="DateTimeOffset"/>.</returns> public static ZonedDateTime FromDateTimeOffset(DateTimeOffset dateTimeOffset) => new ZonedDateTime(Instant.FromDateTimeOffset(dateTimeOffset), new FixedDateTimeZone(Offset.FromTimeSpan(dateTimeOffset.Offset)));
/// <summary> /// Gets the zone interval for the given instant; the range of time around the instant in which the same Offset /// applies (with the same split between standard time and daylight saving time, and with the same offset). /// </summary> /// <remarks> /// This will always return a valid zone interval, as time zones cover the whole of time. /// </remarks> /// <param name="instant">The <see cref="T:NodaTime.Instant" /> to query.</param> /// <returns>The defined <see cref="T:NodaTime.TimeZones.ZoneInterval" />.</returns> /// <seealso cref="GetZoneIntervals(Interval)"/> public abstract ZoneInterval GetZoneInterval(Instant instant);
/// <summary> /// Returns the offset from UTC, where a positive duration indicates that local time is /// later than UTC. In other words, local time = UTC + offset. /// </summary> /// <remarks> /// This is mostly a convenience method for calling <c>GetZoneInterval(instant).WallOffset</c>, /// although it can also be overridden for more efficiency. /// </remarks> /// <param name="instant">The instant for which to calculate the offset.</param> /// <returns> /// The offset from UTC at the specified instant. /// </returns> public virtual Offset GetUtcOffset(Instant instant) => GetZoneInterval(instant).WallOffset;
public void Deconstruct(out Instant?start, out Instant?end) { start = this.start.IsValid ? Start : (Instant?)null; end = this.end.IsValid ? End : (Instant?)null; }
public bool Contains(Instant instant) => instant >= start && instant < end;
public Instant ToInstant() => Instant.FromUntrustedDuration(ToElapsedTimeSinceEpoch());