Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Use static tuple instead of list for aliases (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse authored Mar 3, 2024
1 parent 138be06 commit d82b2e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions stdlib_extensions/datetime/_utils.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ from ..builtins._generic_list import _cmp_list
from ..builtins import custom_hash
from ..builtins import bool_to_int
from .._utils import custom_debug_assert
from utils.static_tuple import StaticTuple


def _cmp(x, y):
Expand All @@ -39,7 +40,7 @@ alias MAXORDINAL = 3652059 # date.max.toordinal()
# -1 is a placeholder for indexing purposes.


alias DAYS_IN_MONTH = list[Int].from_values(
alias DAYS_IN_MONTH = StaticTuple[13](
-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
)

Expand Down Expand Up @@ -178,7 +179,7 @@ fn ord2ymd(owned n: Int) -> Tuple[Int, Int, Int]:


# Month and day names. For localized versions, see the calendar module.
alias MONTHS_SHORT_NAMES = list[String].from_values(
alias MONTHS_SHORT_NAMES = StaticTuple[13](
"",
"Jan",
"Feb",
Expand All @@ -194,7 +195,7 @@ alias MONTHS_SHORT_NAMES = list[String].from_values(
"Dec",
)

alias MONTHS_NAMES = list[String].from_values(
alias MONTHS_NAMES = StaticTuple[13](
"",
"January",
"February",
Expand All @@ -211,7 +212,7 @@ alias MONTHS_NAMES = list[String].from_values(
)


alias DAYS_SHORT_NAMES = list[String].from_values(
alias DAYS_SHORT_NAMES = StaticTuple[8](
"",
"Mon",
"Tue",
Expand All @@ -222,7 +223,7 @@ alias DAYS_SHORT_NAMES = list[String].from_values(
"Sun",
)

alias DAYS_NAMES = list[String].from_values(
alias DAYS_NAMES = StaticTuple[8](
"",
"Monday",
"Tuesday",
Expand Down

0 comments on commit d82b2e8

Please sign in to comment.