Skip to content

Commit

Permalink
refactor: shorter remove zero
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Mar 26, 2024
1 parent 236de73 commit 3b97aa2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ export function fill(
if (partName === "literal") return partValue
const value = partMap[partName]
if (partName === "hour" && token === "H") {
const replacedHour = value.replace(/^0/, "")
return replacedHour === "" ? "0" : replacedHour
return value.replace(/^0/, "") || "0"
}
if (["mm", "ss", "MM"].includes(token) && value.length === 1) {
// Some tokens are supposed to have leading zeros, but Intl doesn't
Expand Down

0 comments on commit 3b97aa2

Please sign in to comment.