# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)
# 
# Path: craft_ai/operators.py
# OPERATORS = OPERATORS_V2
# 
# Path: craft_ai/types.py
# TYPES = {
#     "continuous": "continuous",
#     "enum": "enum",
#     "boolean": "boolean",
#     "timezone": "timezone",
#     "time_of_day": "time_of_day",
#     "day_of_week": "day_of_week",
#     "day_of_month": "day_of_month",
#     "month_of_year": "month_of_year",
# }
# 
# TYPE_ANY = "any"


import datetime
import math
from craft_ai.errors import CraftAiError
from craft_ai.operators import OPERATORS
from craft_ai.types import TYPES, TYPE_ANY
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec",
]


def _time_formatter(time):
    if isinstance(time, datetime.datetime):
        if time.second == 0:
            return time.strftime("%H:%M")
        return time.strftime("%H:%M:%S")
    else:
        hours = int(math.floor(time))
        dec_minutes = (time - hours) * 60
        minutes = int(math.floor(dec_minutes))
        seconds = int(math.floor((dec_minutes - minutes) * 60))

        if seconds > 0:
            return "{:02d}:{:02d}:{:02d}".format(hours, minutes, seconds)
        return "{:02d}:{:02d}".format(hours, minutes)


PROPERTY_FORMATTER = {
    TYPE_ANY: lambda value: value,
    TYPES["continuous"]: lambda number: "{:.2f}".format(number).rstrip("0").rstrip("."),
    TYPES["time_of_day"]: _time_formatter,

# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)
# 
# Path: craft_ai/operators.py
# OPERATORS = OPERATORS_V2
# 
# Path: craft_ai/types.py
# TYPES = {
#     "continuous": "continuous",
#     "enum": "enum",
#     "boolean": "boolean",
#     "timezone": "timezone",
#     "time_of_day": "time_of_day",
#     "day_of_week": "day_of_week",
#     "day_of_month": "day_of_month",
#     "month_of_year": "month_of_year",
# }
# 
# TYPE_ANY = "any"


# Path: craft_ai/formatters.py
import datetime
import math
from craft_ai.errors import CraftAiError
from craft_ai.operators import OPERATORS
from craft_ai.types import TYPES, TYPE_ANY

    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec",
]


def _time_formatter(time):
    if isinstance(time, datetime.datetime):
        if time.second == 0:
            return time.strftime("%H:%M")
        return time.strftime("%H:%M:%S")
    else:
        hours = int(math.floor(time))
        dec_minutes = (time - hours) * 60
        minutes = int(math.floor(dec_minutes))
        seconds = int(math.floor((dec_minutes - minutes) * 60))

        if seconds > 0:
            return "{:02d}:{:02d}:{:02d}".format(hours, minutes, seconds)
        return "{:02d}:{:02d}".format(hours, minutes)


PROPERTY_FORMATTER = {
    TYPE_ANY: lambda value: value,
    TYPES["continuous"]: lambda number: "{:.2f}".format(number).rstrip("0").rstrip("."),
    TYPES["time_of_day"]: _time_formatter,

    TYPES["day_of_week"]: lambda day: DAYS[day.weekday()]