# Path: cms/colander_types.py
# class DateTimeUS(colander.SchemaType):
# class DateUS(colander.SchemaType):
#     def __init__(self, timezone='UTC'):
#     def serialize(self, node, appstruct):
#     def deserialize(self, node, cstruct):
#     def serialize(self, node, appstruct):
#     def deserialize(self, node, cstruct):
# 
# Path: cms/dateutil.py
# def get_timezone_for_request(request=None, default='UTC'):
#     # FIXME: consider making this a user preference
#     if request:
#         return request.registry.settings.get('default_timezone', default)
#     else:
#         return default
# 
# def today_for_request_tz(request):
#     """ Return "today's date" for the request's timezone.
#     Kinda tricky since at any moment there are always two current dates, depending on your local timezone.
#     On the other hand, there's only one UTC date at any moment.
#     """
#     return convert_from_utc_to_request_tz(datetime.datetime.utcnow(), request).date()
# 
# def utcnow(zero_seconds=False):
#     """ Returns a timezone aware version of utcnow.
#     If zero_seconds, the datetime will be rounded down to the minute.
#     """
#     now = datetime.datetime.now(pytz.utc)
#     if zero_seconds: return now.replace(second=0, microsecond=0)
#     return now


from content import Content
from cms import colander_types
from cms.dateutil import get_timezone_for_request, today_for_request_tz, utcnow
import colander, deform
import widgets

# Example implementation of a common content type.
class Article(Content):

    _object_type = "article"

    def get_class_schema(cls, request=None):
        schema = Content.get_class_schema(request)
        #schema.add(colander.SchemaNode(colander_types.DateUS(), name='dateline', default=today_for_request_tz(request)))

# Path: cms/colander_types.py
# class DateTimeUS(colander.SchemaType):
# class DateUS(colander.SchemaType):
#     def __init__(self, timezone='UTC'):
#     def serialize(self, node, appstruct):
#     def deserialize(self, node, cstruct):
#     def serialize(self, node, appstruct):
#     def deserialize(self, node, cstruct):
# 
# Path: cms/dateutil.py
# def get_timezone_for_request(request=None, default='UTC'):
#     # FIXME: consider making this a user preference
#     if request:
#         return request.registry.settings.get('default_timezone', default)
#     else:
#         return default
# 
# def today_for_request_tz(request):
#     """ Return "today's date" for the request's timezone.
#     Kinda tricky since at any moment there are always two current dates, depending on your local timezone.
#     On the other hand, there's only one UTC date at any moment.
#     """
#     return convert_from_utc_to_request_tz(datetime.datetime.utcnow(), request).date()
# 
# def utcnow(zero_seconds=False):
#     """ Returns a timezone aware version of utcnow.
#     If zero_seconds, the datetime will be rounded down to the minute.
#     """
#     now = datetime.datetime.now(pytz.utc)
#     if zero_seconds: return now.replace(second=0, microsecond=0)
#     return now


# Path: cms/resources/article.py
from content import Content
from cms import colander_types
from cms.dateutil import get_timezone_for_request, today_for_request_tz, utcnow
import colander, deform
import widgets


# Example implementation of a common content type.
class Article(Content):

    _object_type = "article"

    def get_class_schema(cls, request=None):
        schema = Content.get_class_schema(request)
        #schema.add(colander.SchemaNode(colander_types.DateUS(), name='dateline', default=today_for_request_tz(request)))

        schema.add(colander.SchemaNode(colander_types.DateTimeUS(get_timezone_for_request(request)), name='dateline', default=utcnow()))