How to use the jdatetime.date.today 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 / jalali_test_2_0 / foo / tests.py View on Github external
def setUp(self):
        self.request_factory = RequestFactory()
        self.today = jdatetime.date.today()
        self.tomorrow = self.today + jdatetime.timedelta(days=1)
        self.one_week_ago = self.today - jdatetime.timedelta(days=7)
        if self.today.month == 12:
            self.next_month = self.today.replace(year=self.today.year + 1, month=1, day=1)
        else:
            self.next_month = self.today.replace(month=self.today.month + 1, day=1)
        self.next_year = self.today.replace(year=self.today.year + 1, month=1, day=1)

        #Bars
        self.mybartime = BarTime.objects.create(name="foo", datetime=self.today)
github slashmili / django-jalali / jalali_test / foo / tests.py View on Github external
def setUp(self):
        self.request_factory = RequestFactory()
        self.today = jdatetime.date.today()
        self.tomorrow = self.today + jdatetime.timedelta(days=1)
        self.one_week_ago = self.today - jdatetime.timedelta(days=7)
        if self.today.month == 12:
            self.next_month = self.today.replace(year=self.today.year + 1, month=1, day=1)
        else:
            self.next_month = self.today.replace(month=self.today.month + 1, day=1)
        self.next_year = self.today.replace(year=self.today.year + 1, month=1, day=1)

        # Bars
        self.mybartime = BarTime.objects.create(name="foo", datetime=self.today)
github slashmili / django-jalali / django_jalali / admin / filterspecs.py View on Github external
def __init__(self, f, request, params, model, model_admin,
                 field_path=None):
        super(jDateFieldFilterSpec, self).__init__(
            f, request, params, model, model_admin, field_path=field_path
        )
        self.field_generic = '%s__' % self.field_path

        self.date_params = dict([(k, v) for k, v in params.items() if k.startswith(self.field_generic)])

        today = jdatetime.date.today()
        one_week_ago = today - jdatetime.timedelta(days=7)
        # today_str = isinstance(self.field, jmodels.DateTimeField) \
        #            and today.strftime('%Y-%m-%d 23:59:59') \
        #            or today.strftime('%Y-%m-%d')
        today_str = today.strftime('%Y-%m-%d')

        last_day_this_month = 29
        if today.month == 12 and today.isleap():
            last_day_this_month = 30
        else:
            last_day_this_month = jdatetime.j_days_in_month[today.month-1]

        last_day_this_year = 29
        if today.isleap():
            last_day_this_year = 30
github slashmili / django-jalali / django_jalali / db / models.py View on Github external
def pre_save(self, model_instance, add):
        if self.auto_now or (self.auto_now_add and add):
            value = jdatetime.date.today()
            setattr(model_instance, self.attname, value)
            return value
        else:
            return super(jDateField, self).pre_save(model_instance, add)