Changed and added more unit tests. Should be good to go now.


On Mon, Jun 17, 2013 at 1:41 PM, chrisndodge <notifications@github.com>wrote:

> In common/lib/xmodule/xmodule/fields.py:
>
> > @@ -26,14 +30,21 @@ def from_json(self, field):
> >          elif field is "":
> >              return None
> >          elif isinstance(field, basestring):
> > -            result = dateutil.parser.parse(field)
> > +            # It's not trivial to replace dateutil b/c parsing timezones as Z, +03:30, -400 is hard in python
> > +            # however, we don't want dateutil to default the month or day (but some tests at least expect
> > +            # us to default year); so, we'll see if dateutil uses the defaults for these the hard way
> > +            result = dateutil.parser.parse(field, default=self.DEFAULT_DATE0)
> > +            result_other = dateutil.parser.parse(field, default=self.DEFAULT_DATE1)
> > +            if result != result_other:
> > +                log.warning("Field {0} is missing month or day".format(self._name, field))
> > +                return None
>
> I wonder for legibility's sake, if you should make a
> is_date_fully_formed(field) method and then inside that method, do this
> "test-via-defaults" and just return True/False.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/edx/edx-platform/pull/183/files#r4729684>
> .
>