persiantools 4.1.0__tar.gz → 4.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {persiantools-4.1.0/persiantools.egg-info → persiantools-4.1.1}/PKG-INFO +1 -1
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools/__init__.py +1 -1
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools/jdatetime.py +1 -1
- {persiantools-4.1.0 → persiantools-4.1.1/persiantools.egg-info}/PKG-INFO +1 -1
- {persiantools-4.1.0 → persiantools-4.1.1}/tests/test_jalalidatetime.py +46 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/LICENSE +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/MANIFEST.in +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/README.md +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools/characters.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools/digits.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools/utils.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools.egg-info/SOURCES.txt +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools.egg-info/dependency_links.txt +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools.egg-info/not-zip-safe +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools.egg-info/requires.txt +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/persiantools.egg-info/top_level.txt +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/pyproject.toml +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/setup.cfg +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/setup.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/tests/test_characters.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/tests/test_digits.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/tests/test_jalalidate.py +0 -0
- {persiantools-4.1.0 → persiantools-4.1.1}/tests/test_utils.py +0 -0
|
@@ -1428,7 +1428,7 @@ class JalaliDateTime(JalaliDate):
|
|
|
1428
1428
|
"%S": "%02d" % self._second,
|
|
1429
1429
|
"%f": "%06d" % self._microsecond,
|
|
1430
1430
|
"%z": datetime.strftime("%z"),
|
|
1431
|
-
"%Z": ("" if not self._tzinfo else self._tzinfo.tzname(
|
|
1431
|
+
"%Z": ("" if not self._tzinfo else self._tzinfo.tzname(datetime)),
|
|
1432
1432
|
"%X": "%02d:%02d:%02d" % (self._hour, self._minute, self._second),
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
@@ -546,3 +546,49 @@ class TestJalaliDateTime(TestCase):
|
|
|
546
546
|
expected = timedelta(days=1)
|
|
547
547
|
|
|
548
548
|
self.assertEqual(result, expected)
|
|
549
|
+
|
|
550
|
+
def test_to_jalali_with_timezone(self):
|
|
551
|
+
dt = datetime.now(timezone.utc)
|
|
552
|
+
jdate = JalaliDateTime.to_jalali(dt)
|
|
553
|
+
self.assertEqual(jdate.tzinfo, timezone.utc)
|
|
554
|
+
|
|
555
|
+
def test_strftime_basic(self):
|
|
556
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45)
|
|
557
|
+
self.assertEqual(jdate.strftime("%Y-%m-%d %H:%M:%S"), "1400-01-01 15:30:45")
|
|
558
|
+
|
|
559
|
+
def test_strftime_locale_fa(self):
|
|
560
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45, locale="fa")
|
|
561
|
+
self.assertEqual(jdate.strftime("%Y-%m-%d %H:%M:%S", locale="fa"), "۱۴۰۰-۰۱-۰۱ ۱۵:۳۰:۴۵")
|
|
562
|
+
|
|
563
|
+
def test_strftime_with_timezone_utc(self):
|
|
564
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45, tzinfo=timezone.utc)
|
|
565
|
+
self.assertEqual(jdate.strftime("%Y-%m-%d %H:%M:%S %Z"), "1400-01-01 15:30:45 UTC")
|
|
566
|
+
|
|
567
|
+
def test_strftime_with_timezone_offset(self):
|
|
568
|
+
tz = timezone(timedelta(hours=3, minutes=30))
|
|
569
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45, tzinfo=tz)
|
|
570
|
+
self.assertEqual(jdate.strftime("%Y-%m-%d %H:%M:%S %z"), "1400-01-01 15:30:45 +0330")
|
|
571
|
+
|
|
572
|
+
def test_strftime_with_abbreviated_month_day(self):
|
|
573
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45)
|
|
574
|
+
self.assertEqual(jdate.strftime("%b %a"), "Far Yek")
|
|
575
|
+
|
|
576
|
+
def test_strftime_with_full_month_day(self):
|
|
577
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45)
|
|
578
|
+
self.assertEqual(jdate.strftime("%B %A"), "Farvardin Yekshanbeh")
|
|
579
|
+
|
|
580
|
+
def test_strftime_with_custom_format(self):
|
|
581
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45)
|
|
582
|
+
self.assertEqual(jdate.strftime("%d %B %Y - %H:%M"), "01 Farvardin 1400 - 15:30")
|
|
583
|
+
|
|
584
|
+
def test_strftime_with_persian_locale(self):
|
|
585
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45, locale="fa")
|
|
586
|
+
self.assertEqual(jdate.strftime("%A, %d %B %Y - %H:%M", locale="fa"), "یکشنبه, ۰۱ فروردین ۱۴۰۰ - ۱۵:۳۰")
|
|
587
|
+
|
|
588
|
+
def test_strftime_with_periodic_time(self):
|
|
589
|
+
jdate = JalaliDateTime(1400, 1, 1, 15, 30, 45)
|
|
590
|
+
self.assertEqual(jdate.strftime("%I:%M %p"), "03:30 PM")
|
|
591
|
+
|
|
592
|
+
def test_strftime_edge_case_midnight(self):
|
|
593
|
+
jdate = JalaliDateTime(1400, 1, 1, 0, 0, 0)
|
|
594
|
+
self.assertEqual(jdate.strftime("%Y-%m-%d %H:%M:%S"), "1400-01-01 00:00:00")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|