The year, month, day, weekday, hour, minute and second of a time or a date and time that is one of the seconds of a set (D-109).
A time or a date and time with a set ({:date_and_time, set}, Feel.Type.Moment) is one whose second is in the
set, on the line of the clock of the values with no zone, or on the line of the instants and the zoned clock of
those with one. The properties of Table 67 are those of the clock (2021-01-31T23:30:00+01:00 has the hour 23,
and its instant is at 22), so they are the properties of the seconds of the two lines of clocks together, which
select/3 computes:
| Property | The set |
|---|---|
year, month, day, weekday | those of the days that the seconds are in (Feel.Analysis.DateProperties) |
hour, minute | the hours (minutes) of the seconds of each interval, which are all of them if the interval is longer than a day (an hour), and are counted from one end to the other otherwise |
second | the whole second of each and the fraction of it (D-118): [s..s+1) for the seconds s that there are if the fraction is not known, s for whole seconds, s + 0.5 |
The properties that depend on the zone (value, time offset, timezone) are worked out by
Feel.Analysis.MomentZones (D-109).
restrict/4 is the other way round: a condition on the property of a name (dt.month > 6) leaves the seconds of
the set that have it, on each line of clocks, and the line of the instants is cut to match. The seconds of the days
are exact (DateProperties.restrict/3); those of the hours, the minutes and the seconds are the seconds of each day,
hour or minute of the interval, up to a number of pieces, and past it the set is left as it is.
iex> alias Feel.Type.{Moment, NumberSet}
iex> {:ok, date_time} = Feel.Value.DateTime.parse("2021-03-01T00:00:00")
iex> {:ok, [first]} = Moment.images(date_time)
iex> last = Decimal.add(first, 86_399)
iex> day = NumberSet.interval(first, last)
iex> {:ok, hour, :never} = Feel.Analysis.MomentProperties.select(:date_and_time, day, "hour")
iex> Feel.Type.Union.format(hour)
"number in [0..23]"
iex> {:ok, month, :never} = Feel.Analysis.MomentProperties.select(:date_and_time, day, "month")
iex> Feel.Type.Union.format(month)
"number = 3"
Summary
Functions
The properties of the clock of a kind, which select/3 and restrict/4 know.
The set of a time or a date and time cut to the seconds whose year, month, day, weekday, hour, minute or
second is one of the numbers that members has, or :error if they are not worked out (the pieces are many).
members is the type that a condition leaves of the property, so the value is one of the seconds that have it.
The type of the property key of a time or a date and time in the set, and whether selecting it can be an error; or
:error if the set has no second or the property is not known. The properties of the zone (value, time offset and
timezone) are those of Feel.Analysis.MomentZones.
Functions
@spec keys(Feel.Type.Moment.kind()) :: [String.t()]
The properties of the clock of a kind, which select/3 and restrict/4 know.
@spec restrict(Feel.Type.Moment.kind(), Feel.Type.NumberSet.t(), String.t(), [ Feel.Type.Union.member() ]) :: {:ok, Feel.Type.NumberSet.t()} | :error
The set of a time or a date and time cut to the seconds whose year, month, day, weekday, hour, minute or
second is one of the numbers that members has, or :error if they are not worked out (the pieces are many).
members is the type that a condition leaves of the property, so the value is one of the seconds that have it.
iex> alias Feel.Type.{Moment, NumberSet}
iex> {:ok, from} = Feel.Value.DateTime.parse("2021-03-01T00:00:00")
iex> {:ok, to} = Feel.Value.DateTime.parse("2021-03-01T23:59:59")
iex> {:ok, [first]} = Moment.images(from)
iex> {:ok, [last]} = Moment.images(to)
iex> day = NumberSet.interval(first, last)
iex> later = [{:number, NumberSet.interval({Decimal.new(18), :closed}, Decimal.new(23))}]
iex> {:ok, evening} = Feel.Analysis.MomentProperties.restrict(:date_and_time, day, "hour", later)
iex> Feel.Type.Union.format([{:date_and_time, evening}])
"date and time in [2021-03-01T18:00:00..2021-03-01T23:59:59]"
@spec select(Feel.Type.Moment.kind(), Feel.Type.NumberSet.t(), String.t()) :: {:ok, Feel.Type.Union.t(), :never | :maybe | :always} | :error
The type of the property key of a time or a date and time in the set, and whether selecting it can be an error; or
:error if the set has no second or the property is not known. The properties of the zone (value, time offset and
timezone) are those of Feel.Analysis.MomentZones.