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

Manual example 1 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

daytoyear(Me_1) inside calc: numbers of days to years and days.

Manual:

Number days to duration, Example 1: "The operator daytoyear returns a duration having the following mask", \PY\YDDD\D, with the years and days "according to ISO 8601 Y = 365D".

Expected:

The manual's durations, P0Y240D, P1Y359D and P2Y326D, a String Me_2: 240, 365 + 359 and 2 × 365 + 326 days.

Erratum:

The manual's output repeats Id_1 = G on its second data point, where DS_1 has H: the calc keeps the identifiers of DS_1, and two data points cannot share the key G. 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 := daytoyear(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
G240P0Y240D
H724P1Y359D
T1056P2Y326D

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"}
      ]
    }
  ]
}