Years and days to number of days · yeartoday
---
config:
flowchart:
useMaxWidth: false
---
flowchart TB
classDef ok fill:#d4edda,stroke:#28a745,color:#000
classDef partial fill:#fff3cd,stroke:#ffc107,color:#000
classDef refused fill:#d4edda,stroke:#28a745,stroke-width:3px,stroke-dasharray: 2 2,color:#000
classDef missing fill:#f8d7da,stroke:#dc3545,color:#000
classDef diverge fill:#cce5ff,stroke:#007bff,color:#000
classDef block fill:#2b3a4a,stroke:#2b3a4a,color:#fff,font-weight:bold
classDef ext fill:#fff,stroke:#666,color:#000,stroke-dasharray: 5 5
O["Years and days to number of days · yeartoday 📌<br/>🟢2"]:::ok
subgraph G_comp["Component"]
direction LR
v_comp["calc yeartoday(comp) 📌"]:::ok
end
subgraph G_sc["Scalar"]
direction LR
v_sc["yeartoday(sc) 📌"]:::ok
end
O --- G_comp
O --- G_sc
style G_comp fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 8 5
style G_sc fill:#f8f9fa,stroke:#495057,stroke-width:2px,stroke-dasharray: 2 3
click v_comp href "#form-comp"
click v_sc href "#form-sc"
Types
Takes duration · Gives integer
Comes from · duration — 4 operators in 2 blocks 🟢4
General purpose operators (1) 🟢1
Comes from · operators that return any type (their input's) — 39 operators in 9 blocks 🟢39
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Time operators (3) 🟢3
Set operators (4) 🟢4
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (8) 🟢8
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Goes to · integer — 44 operators in 8 blocks 🟢44
General purpose operators (1) 🟢1
String operators (2) 🟢2
Numeric operators (18) 🟢18
Time operators (6) 🟢6
Hierarchical aggregation (1) 🟢1
Aggregate and Analytic operators (10) 🟢10
Data validation operators (2) 🟢2
Definitions (VTL-DL) (4) 🟢4
Goes to · operators that take any scalar — 46 operators in 8 blocks 🟢46
General purpose operators (6) 🟢6
Join operators (4) 🟢4
Comparison operators (11) 🟢11
Set operators (4) 🟢4
Aggregate and Analytic operators (8) 🟢8
Data validation operators (1) 🟢1
Conditional operators (3) 🟢3
Forms
calc yeartoday(comp) 🟢 · duration → integer
Manual example 1 🟢 pandas ✅ · DuckDB ✅
- Tests:
yeartoday(Me_1)insidecalc, onP2Y230D,P1Y23DandP3Y152Das the manual writes them, in a StringMe_1where the manual declares a Duration.- Manual:
Duration to number days, Example 1:
yearDurationis “a duration having the following mask”,\PY\YDDD\D, and the result is “the number of days corresponding to the given duration”, “according to ISO 8601 Y = 365D”.- Expected:
Derived from that rule:
Me_2is 960 (2 × 365 + 230), 388 (365 + 23) and 1247 (3 × 365 + 152), Integers.- Erratum:
The manual’s output is that of Example 1 of Number days to duration, its repeated
Gincluded: itsMe_1holds numbers of days whereDS_1holds durations, and itsMe_2durations where its structure says Integer.- Team decision:
#394: a Duration holds only a period indicator (
A,S,Q,M,W,D), so the ISO 8601 durations thatdaytoyearanddaytomonthreturn andyeartodayandmonthtodaytake are Strings.
DS_r:= DS_1[calc Me_2 := yeartoday (Me_1)];
| Id_1 | Me_1 |
|---|---|
| G | P2Y230D |
| H | P1Y23D |
| T | P3Y152D |
| Id_1 | Me_1 | Me_2 |
|---|---|---|
| G | P2Y230D | 960 |
| H | P1Y23D | 388 |
| T | P3Y152D | 1247 |
Files: script.vtl · input/DS_1.csv · input/DS_1.json · expected/DS_r.csv · expected/DS_r.json · example page ↗
yeartoday(sc) 🟢 · duration → integer
One year and twenty days 🟢 pandas ✅ · DuckDB ✅
- Tests:
yeartoday(SC_1)withSC_1=P1Y20D, a String, the page’s Example 2.- Manual:
Duration to number days:
yeartoday (P1Y20D);“returns 385”, “according to ISO 8601 Y = 365D”.- Expected:
DS_r = 385, an Integer: 365 + 20.- Team decision:
#394: a Duration holds only a period indicator (
A,S,Q,M,W,D), so the ISO 8601 durations thatdaytoyearanddaytomonthreturn andyeartodayandmonthtodaytake are Strings.
DS_r := yeartoday(SC_1);
| SC_1 |
|---|
| P1Y20D |
Name |
Type |
Value |
|---|---|---|
|
Integer |
|
Files: script.vtl · input/scalars.csv · input/scalars.json · expected/scalars.json · example page ↗