Skip to main content
Skip table of contents

HCMS Schema - Time Features

Describes the particularities of handling asset features that include time values.

There are two possible mappings of time related features in JSON, depending on the JSON type:

  • integer or number: the number of milliseconds (from 1.1.1970, or start of the day/month/year in case of partial values)
  • string: ISO8601 representation in extended format (i.e. with separators)

Date and Time (Timestamp)

Example of the definition of a timestamp value "approved" mapped to string in ISO8601 format:

JSON
{
  "type": "object",
  "properties": {
    "approved": {
      "cs:value_type": "timestamp",
      "cs:feature.key": "censhare:approved-date",
      "type": "string"
    }
  }
}

An example entity looks like this:

JSON
{
  "approved": "2009-05-04T11:21:57Z"
}

The same example, but with type integer or number instead of string type returns the value in milliseconds:

JSON
{
  "approved": 1241436117000
}

Date

Birthdays are a fine example of a date without any time information, as illustrated below:

JSON
{
  "type": "object",
  "properties": {
    "birthday": {
      "cs:value_type": "date",
      "type": "string"
    }
  }
}

Sample entity:

JSON
{
  "birthday": "1879-03-14"
}

Time Ranges

Time ranges, like business hours, are represented by features of type TIME_PAIR. These are internally stored as features with two values, value_timestamp and value_timestamp2. These values can be mapped as individual child properties (e.g. "from" and "till") inside a bracket JSON object (e.g. "businessHours"). The schema properties "cs:feature.$value_property" and "cs:feature.$value_property" respectively are used to specify the individual child properties for mapping.

Example schema:

JSON
{
    "type": "object",
    "properties": {
        "businessHours": {
            "type": "object",
            "cs:feature.key": "censhare:resource-availability.period",
            "cs:feature.$value_property": "from",
            "cs:feature.$value2_property": "till",
            "properties": {
                "from": {
                    "type": "string"
                },
                "till": {
                    "type": "string"
                }
            },
            "required": [
                "from",
                "till"
            ]
        }
    }
}

Sample entity:

JSON
{
  "businessHours": {
    "till": "13:00:00",
    "from": "09:00:00"
  }
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.