TimeType Enumeration

Assembly: CodeEffects.Rule.Common.dll
Namespace: CodeEffects.Rule.Common.Models

Summary

Specifies what a System.TimeSpan member of a source object holds: a time of day, as in all earlier versions, or a duration.

Syntax

public enum TimeType
{
	// A time of day, from 00:00 to 23:59:59, shown and picked as one. The default
	TimeOfDay = 0,

	// A length of time in the units its DateTimeFormat names, the largest unbounded
	Duration = 1
}

Remarks

Set the type through the TimeType property of the FieldAttribute, ParameterAttribute and ReturnAttribute attributes, or in the settings of the Adaptive Source. It applies to fields, method parameters and method return values of type System.TimeSpan or System.TimeSpan?, and to the items of value collections of them. The numeric values are permanent.

A duration's DateTimeFormat names its units with the tokens of TimeSpan: d, h or hh, m or mm, s or ss. The largest unit in the format is unbounded, so with hh:mm a value of 900 hours reads 900:00. A unit that the format lacks is not part of the value. When no format is set, a duration uses d.hh:mm.

A duration is compared with, passed as, set from, or returned into only another duration, and a time of day only another time of day. System.TimeOnly is always a time of day: setting Duration on a TimeOnly member is refused when the source object is loaded.

Example

using System;
using CodeEffects.Rule.Common.Attributes;
using CodeEffects.Rule.Common.Models;

public class Shipment
{
	// Shown and picked as a duration, such as 900h 0m
	[Field(TimeType = TimeType.Duration, DateTimeFormat = "hh:mm")]
	public TimeSpan TransitTime { get; set; }
}

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×