← yeartoday operator page · time/yeartoday/comp/manual_ex_1

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

yeartoday(Me_1) inside calc, on P2Y230D, P1Y23D and P3Y152D as the manual writes them, in a String Me_1 where the manual declares a Duration.

Manual:

Duration to number days, Example 1: yearDuration is "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_2 is 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 G included: its Me_1 holds numbers of days where DS_1 holds durations, and its Me_2 durations 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 that daytoyear and daytomonth return and yeartoday and monthtoday take are Strings.

script.vtl ⇩

DS_r:= DS_1[calc Me_2 := yeartoday (Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
GP2Y230D
HP1Y23D
TP3Y152D

input/DS_1.json ⇩

{
  "datasets": [
    {
      "name": "DS_1",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
        {"name": "Me_1", "type": "String", "role": "Measure", "nullable": true}
      ]
    }
  ]
}

expected/DS_r.csv ⇩

Id_1Me_1Me_2
GP2Y230D960
HP1Y23D388
TP3Y152D1247

expected/DS_r.json ⇩

{
  "datasets": [
    {
      "name": "DS_r",
      "DataStructure": [
        {"name": "Id_1", "type": "String", "role": "Identifier"},
        {"name": "Me_1", "type": "String", "role": "Measure"},
        {"name": "Me_2", "type": "Integer", "role": "Measure"}
      ]
    }
  ]
}