Skip to content

Commit

Permalink
fix: remove formating lines
Browse files Browse the repository at this point in the history
  • Loading branch information
alaa-yahia committed Jan 6, 2025
1 parent 8ce68dd commit b0dc55c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 24 deletions.
7 changes: 2 additions & 5 deletions src/core_modules/capture-core/converters/clientToForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ type RangeValue = {
}

function convertDateForEdit(rawValue: string): string {
const momentDate = moment(rawValue);
const dateString = momentDate.format('YYYY-MM-DD');
return convertIsoToLocalCalendar(dateString);
return convertIsoToLocalCalendar(rawValue);
}

function convertDateTimeForEdit(rawValue: string): DateTimeFormValue {
const dateTime = moment(rawValue);
const dateString = dateTime.format('YYYY-MM-DD');
const timeString = dateTime.format('HH:mm');
return {
date: convertIsoToLocalCalendar(dateString),
date: convertIsoToLocalCalendar(rawValue),
time: timeString,
};
}
Expand Down
7 changes: 2 additions & 5 deletions src/core_modules/capture-core/converters/clientToList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import { MinimalCoordinates } from '../components/MinimalCoordinates';
import { TooltipOrgUnit } from '../components/Tooltips/TooltipOrgUnit';

function convertDateForListDisplay(rawValue: string): string {
const momentDate = moment(rawValue);
const dateString = momentDate.format('YYYY-MM-DD');
return convertIsoToLocalCalendar(dateString);
return convertIsoToLocalCalendar(rawValue);
}

function convertDateTimeForListDisplay(rawValue: string): string {
const momentDate = moment(rawValue);
const dateString = momentDate.format('YYYY-MM-DD');
const timeString = momentDate.format('HH:mm');
const localDate = convertIsoToLocalCalendar(dateString);
const localDate = convertIsoToLocalCalendar(rawValue);
return `${localDate} ${timeString}`;
}

Expand Down
7 changes: 2 additions & 5 deletions src/core_modules/capture-core/converters/clientToView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import { TooltipOrgUnit } from '../components/Tooltips/TooltipOrgUnit';


function convertDateForView(rawValue: string): string {
const momentDate = moment(rawValue);
const dateString = momentDate.format('YYYY-MM-DD');
return convertIsoToLocalCalendar(dateString);
return convertIsoToLocalCalendar(rawValue);
}
function convertDateTimeForView(rawValue: string): string {
const momentDate = moment(rawValue);
const dateString = momentDate.format('YYYY-MM-DD');
const timeString = momentDate.format('HH:mm');

const localDate = convertIsoToLocalCalendar(dateString);
const localDate = convertIsoToLocalCalendar(rawValue);
return `${localDate} ${timeString}`;
}

Expand Down
8 changes: 2 additions & 6 deletions src/core_modules/capture-core/converters/formToClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ function convertDateTime(formValue: DateTimeValue): ?string {

function convertDate(dateValue: string) {
const parsedDate = parseDate(dateValue);
if (!parsedDate.isValid || !parsedDate.momentDate) {
return null;
}
const formattedDate = parsedDate.momentDate.format('YYYY-MM-DD');

return convertLocalToIsoCalendar(formattedDate);
// $FlowFixMe[incompatible-use] automated comment
return parsedDate.isValid ? convertLocalToIsoCalendar(parsedDate.momentDate.toISOString()) : null;
}

function convertTime(timeValue: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ export function convertLocalToIsoCalendar(localDate: ?string): string {
if (!localDate) {
return '';
}

const momentDate = moment(localDate);
if (!momentDate.isValid()) {
return '';
}

const formattedIsoDate = momentDate.format('YYYY-MM-DD');

const calendar = systemSettingsStore.get().calendar;

const { year, month, day } = convertToIso8601(localDate, calendar);
const { year, month, day } = convertToIso8601(formattedIsoDate, calendar);
const dateString = `${padWithZeros(year, 4)}-${padWithZeros(month, 2)}-${padWithZeros(day, 2)}`;
const parsedMoment = moment(dateString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { systemSettingsStore } from '../../../metaDataMemoryStores';
* Converts a string date to a string date with default format based on the system date format
* @export
* @param {*} string - the string instance
* @param {string} [format] - optional date format. If not provided, the function uses system date format
* @returns {string}
*/
export function convertStringToDateFormat(date: string, format) {
export function convertStringToDateFormat(date: string, format?: string) {
if (!date || !date.length) { return ''; }
const dateFormat = format || systemSettingsStore.get().dateFormat;
const formattedDateString = moment(date, dateFormat).format(dateFormat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class DateField extends React.Component<Props, State> {
value,
innerMessage,
} = this.props;
console.log(calendarMax,"calendarMax")
const calculatedInputWidth = inputWidth || width;
const calculatedCalendarWidth = calendarWidth || width;
const calendarType = systemSettingsStore.get().calendar || 'gregory';
Expand Down

0 comments on commit b0dc55c

Please sign in to comment.