# Path: src/pycrunchbase/resource/utils.py
# def parse_date(datelike):
#     """Helper for parsing dates in Organization properties"""
#     try:
#         return datetime.strptime(datelike, "%Y-%m-%d")
#     except ValueError:
#         return datelike


import six
from .node import Node
from .utils import parse_date



@six.python_2_unicode_compatible
class Job(Node):
    """Represents a Job on CrunchBase"""

    KNOWN_PROPERTIES = [
        "title",
        "is_current",
        "started_on",
        "started_on_trust_code",
        "ended_on",
        "ended_on_trust_code",
        "created_at",
        "updated_at",
    ]

    KNOWN_RELATIONSHIPS = [
        "person",
        "organization",
    ]

    def _coerce_values(self):
        for attr in ['started_on', 'ended_on']:
            if getattr(self, attr, None):

# Path: src/pycrunchbase/resource/utils.py
# def parse_date(datelike):
#     """Helper for parsing dates in Organization properties"""
#     try:
#         return datetime.strptime(datelike, "%Y-%m-%d")
#     except ValueError:
#         return datelike


# Path: src/pycrunchbase/resource/job.py
import six
from .node import Node
from .utils import parse_date




@six.python_2_unicode_compatible
class Job(Node):
    """Represents a Job on CrunchBase"""

    KNOWN_PROPERTIES = [
        "title",
        "is_current",
        "started_on",
        "started_on_trust_code",
        "ended_on",
        "ended_on_trust_code",
        "created_at",
        "updated_at",
    ]

    KNOWN_RELATIONSHIPS = [
        "person",
        "organization",
    ]

    def _coerce_values(self):
        for attr in ['started_on', 'ended_on']:
            if getattr(self, attr, None):

                setattr(self, attr, parse_date(getattr(self, attr)))