← daytomonth operator page · time/daytomonth/comp/manual_ex_2

Manual example 2 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

daytomonth(Me_1) inside calc: numbers of days to months and days.

Manual:

Number days to duration, Example 2: "The operator daytomonth returns a duration having the following mask", \PM\MDD\D, with the months and days "according to ISO 8601 M = 30D".

Expected:

The manual's durations, P8M0D, P24M4D and P35M6D, a String Me_2: 8 × 30, 24 × 30 + 4 and 35 × 30 + 6 days.

Erratum:

As in the page's Example 1, of daytoyear, the manual's output repeats Id_1 = G on its second data point, where DS_1 has H; the expected output has H.

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 := daytomonth(Me_1)];

input/DS_1.csv ⇩

Id_1Me_1
G240
H724
T1056

input/DS_1.json ⇩

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

expected/DS_r.csv ⇩

Id_1Me_1Me_2
G240P8M0D
H724P24M4D
T1056P35M6D

expected/DS_r.json ⇩

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