kiara_modules.core.date¶
A collection of date related modules.
Most of those are very bare-bones, not really dealing with more advanced (but very important) concepts like timezones and resolution yet.
        DateRangeCheckModule
¶
    Check whether a date falls within a specified date range.
If none one of the inputs 'earliest' or 'latest' is set, this module will always return 'True'.
Return True if that's the case, otherwise False.
create_input_schema(self)
¶
    Abstract method to implement by child classes, returns a description of the input schema of this module.
If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):
{
      "[input_field_name]: {
          "type": "[value_type]",
          "doc*": "[a description of this input]",
          "optional*': [boolean whether this input is optional or required (defaults to 'False')]
      "[other_input_field_name]: {
          "type: ...
          ...
      }
Source code in core/date.py
          def create_input_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:
    inputs: typing.Dict[str, typing.Dict[str, typing.Any]] = {
        "date": {"type": "date", "doc": "The date to check."},
        "earliest": {
            "type": "date",
            "doc": "The earliest date that is allowed.",
            "optional": True,
        },
        "latest": {
            "type": "date",
            "doc": "The latest date that is allowed.",
            "optional": True,
        },
    }
    return inputs
create_output_schema(self)
¶
    Abstract method to implement by child classes, returns a description of the output schema of this module.
If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):
{
      "[output_field_name]: {
          "type": "[value_type]",
          "doc*": "[a description of this output]"
      "[other_input_field_name]: {
          "type: ...
          ...
      }
Source code in core/date.py
          def create_output_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:
    outputs = {
        "within_range": {
            "type": "boolean",
            "doc": "A boolean indicating whether the provided date was within the allowed range ('true'), or not ('false')",
        }
    }
    return outputs
        ExtractDateModule
¶
    Extract a date object from a string.
This module is not really smart yet, currently it uses the following regex to extract a date (which might fail in a lot of cases):
r"_(\d{4}-\d{2}-\d{2})_"
create_input_schema(self)
¶
    Abstract method to implement by child classes, returns a description of the input schema of this module.
If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):
{
      "[input_field_name]: {
          "type": "[value_type]",
          "doc*": "[a description of this input]",
          "optional*': [boolean whether this input is optional or required (defaults to 'False')]
      "[other_input_field_name]: {
          "type: ...
          ...
      }
Source code in core/date.py
          def create_input_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:
    return {"text": {"type": "string", "doc": "The input string."}}
create_output_schema(self)
¶
    Abstract method to implement by child classes, returns a description of the output schema of this module.
If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):
{
      "[output_field_name]: {
          "type": "[value_type]",
          "doc*": "[a description of this output]"
      "[other_input_field_name]: {
          "type: ...
          ...
      }
Source code in core/date.py
          def create_output_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:
    return {
        "date": {"type": "date", "doc": "The date extracted from the input string."}
    }