예제 #1
0
async def g2j(y: int, m: int, d: int, request: Request, iso: bool = False):
    arg_check(("y", "m", "d", "iso"), request.query_params.keys())

    if y not in range(*g_year_range):
        raise HTTPException(status_code=404)

    try:
        g = date(year=y, month=m, day=d)
        j = JalaliDate(g)
        if iso:
            return {"j": j.isoformat()}
        return {
            "j": {
                "y": j.year,
                "m": j.month,
                "d": j.day
            },
        }
    except Exception:
        raise HTTPException(status_code=404)
예제 #2
0
 def test_iso_format(self):
     jdate = JalaliDate(self.leap_year, 12, 23)
     self.assertEqual(jdate.isoformat(), '%s-12-23' % self.leap_year)
예제 #3
0
 def test_str(self):
     d1 = JalaliDate(1361, 6, 15)
     self.assertEqual(d1.__str__(), d1.isoformat())
예제 #4
0
 def test_iso_format(self):
     jdate = JalaliDate(self.leap_year, 12, 23)
     self.assertEqual(jdate.isoformat(), '%s-12-23' % self.leap_year)
예제 #5
0
 def test_str(self):
     d1 = JalaliDate(1361, 6, 15)
     self.assertEqual(
         d1.__str__(),
         d1.isoformat()
     )