How to use the jdatetime.datetime.strptime function in jdatetime

To help you get started, we’ve selected a few jdatetime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slashmili / django-jalali / django_jalali / db / models.py View on Github external
('%Y-%m-%d', 3),
        ]
        for format, c in formats:
            try:  # Seconds are optional, so try converting seconds first.
                t = time.strptime(datetime_obj, format)
                if t.tm_year > 1700:
                    return datetime.datetime(
                        *time.strptime(datetime_obj, format)[:c],
                        **kwargs)
                else:
                    return jdatetime.datetime(
                        *time.strptime(datetime_obj, format)[:c],
                        **kwargs)
            except ValueError:
                try:
                    return jdatetime.datetime.strptime(
                        datetime_obj,
                        '%Y-%m-%d %H:%M'
                    ).replace(**kwargs)
                except ValueError:
                    pass

        raise exceptions.ValidationError(self.error_messages['invalid'])
github a-roomana / django-jalali-date / jalali_date / fields.py View on Github external
def strptime(self, value, format):
        return jalali_datetime.strptime(force_str(value), format).togregorian()
github a-roomana / django-jalali-date / jalali_date / fields.py View on Github external
def strptime(self, value, format):
        return jalali_datetime.strptime(force_str(value), format).togregorian().date()