Skip to content

Commit

Permalink
fix: prevent moment from using arabic numerals for dates [DHIS2-15277] (
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp authored Jun 19, 2023
1 parent dc69176 commit d822b8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
getAdjacentFixedPeriods,
getFixedPeriodByDate,
} from '@dhis2/multi-calendar-dates'
import moment from 'moment'
import { useMemo } from 'react'
import {
selectors,
Expand All @@ -21,7 +20,8 @@ export const computePeriodDateLimit = ({
openFuturePeriods = 0,
}) => {
const calendar = 'gregory'
const date = moment(serverDate).format('yyyy-MM-DD')
// serverDate is converted to YYYY-MM-DD string named date before being passed
const date = serverDate.toLocaleDateString('sv')
const currentPeriod = getFixedPeriodByDate({
periodType,
date,
Expand Down
4 changes: 2 additions & 2 deletions src/context-selection/period-selector-bar-item/use-periods.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { generateFixedPeriods } from '@dhis2/multi-calendar-dates'
import moment from 'moment'
import { useMemo } from 'react'
import {
formatJsDateToDateString,
Expand Down Expand Up @@ -35,7 +34,8 @@ export default function usePeriods({
const yearForGenerating = isYearlyPeriodType
? year + openFuturePeriods
: year
const endsBefore = moment(dateLimit).format('yyyy-MM-DD')
// dateLimit is converted to YYYY-MM-DD string named endsBefore before being passed
const endsBefore = dateLimit.toLocaleDateString('sv')

const generateFixedPeriodsPayload = {
calendar,
Expand Down

1 comment on commit d822b8c

@dhis2-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.