Days of Operation

As described in the HAFAS Raw data file format documentation, the days of operation of a service are at first a bit field with the length of the timetable period. To shorten this, 4 bits are combined in one hexadecimal digit, which are in the field sDaysB.

Please note that the following information is only confirmed to be valid for DB HAFAS, but may work for other HAFAS instances.

The timetable period, represented as begin and end date, is given in the two fields fpB ("Fahrplanbeginn") and fpE ("Fahrplanende").

For example, when a train runs Monday to Friday every week in the timetable period starting at 2021-12-12 (a sunday), the beginning of the field sDaysB would look as following:

7CF9F3E7...

Converting each hex digit separately back to binary digits, it looks like this:

0111 1100 1111 1001 1111 0011 1110 0111 ...

From this, you can read out each operation day:

SunMonTueWed
0111
ThuFriSatSun
1100
MonTueWedThu
1111
...
...

Furthermore, the Days of Operation can also be found as human-readable text in the optional field sDaysR. In the example above, it would be just "Mo - Fr". For more complicated Days of Operation, this text also gets more complicated, obviously. Thus,

{
  "sDaysB": "00F1E3E7CF9F3E7CF80000001F3E7C000367C01F3A7C7800000000000001F3E7C00000000000000E000000000000"
}

results in runs 25., 26. Aug, 24. until 26. Oct 2022.

When looking at sDaysB, you can see that even before August 25th this train operates, but in the text only the Days of Operation in the future are displayed.

In the following (shortened) response you can see where all fields are located:

JSON response
{
  "svcResL": [
    {
      "res": {
        "outConL": [
          {
            "sDays": {
              // human-readable version operation dates (only contains future days)
              "sDaysR": "runs 25., 26. Aug, 24. until 26. Oct 2022 ",
              // bit field
              "sDaysB": "00F1E3E7CF9F3E7CF80000001F3E7C000367C01F3A7C7800000000000001F3E7C00000000000000E000000000000"
            }
          }
        ],
        // begin of planning period in YYYYMMDD
        "fpB": "20211212",
        // end of planning period in YYYYMMDD
        "fpE": "20221210"
      }
    }
  ]
}