コード例 #1
0
        /// <summary>
        /// Builds a new <see cref="DateTimeExpression"/> with both <paramref name="date"/> and <paramref name="time"/>
        /// specified.
        /// </summary>
        /// <param name="date">date part of the expression</param>
        /// <param name="time">time part of the expression</param>
        /// <param name="offset">offset with the UTC time</param>
        /// <exception cref="ArgumentException">if both <paramref name="date"/> and <paramref name="time"/> are <c>null</c>.</exception>
        public DateTimeExpression(DateExpression date, TimeExpression time, OffsetExpression offset)
        {
            if (date is null && time is null)
            {
                throw new ArgumentException($"Both {nameof(date)} and {nameof(time)} cannot be null and ");
            }

            Date   = date;
            Time   = time;
            Offset = offset;
            Kind   = offset is not null
                ? DateTimeExpressionKind.Utc
                : DateTimeExpressionKind.Unspecified;

            _lazyEscapedParseableString = new(() => (date, time, offset) switch
            {
                ({ }, { }, { }) => $"{date.EscapedParseableString}T{time.EscapedParseableString}{offset.EscapedParseableString}",
コード例 #2
0
 /// <summary>
 /// Builds a new <see cref="DateTimeExpression"/> with both <paramref name="date"/> and <paramref name="time"/>
 /// specified.
 /// </summary>
 /// <param name="date">date part of the expression</param>
 /// <param name="time">time part of the expression</param>
 /// <exception cref="ArgumentException">if both <paramref name="date"/> and <paramref name="time"/> are <c>null</c>.</exception>
 public DateTimeExpression(DateExpression date, TimeExpression time) : this(date, time, null)
 {
 }
コード例 #3
0
 /// <summary>
 /// Builds a new <see cref="DateTimeExpression"/> where only the <see cref="Time"/> part is specified
 /// </summary>
 /// <param name="time"></param>
 /// <exception cref="ArgumentNullException">if <paramref name="time"/> is <c>null</c>.</exception>
 public DateTimeExpression(TimeExpression time) : this(null, time)
 {
 }