|
- import dates from '../date/dates';
-
- export const registryRemoveMask = (cnpj: string): string => cnpj?.replace(/\D/gm, '') || '';
-
- export const competenceDescriptionToDate = (competenceDescription: string): string => {
- const [monthDescription, year] = competenceDescription.split('de');
-
- const month = dates.find(date => {
- const dateDescriptionNormalized = date.description.toLocaleLowerCase('en-US').trim();
- const monthDescriptionNormalized = monthDescription.toLocaleLowerCase('en-US').trim();
-
- return dateDescriptionNormalized === monthDescriptionNormalized;
- })?.value;
-
- const monthFormatted = `00${month}`.slice(-2);
-
- return `${monthFormatted}/${year.trim()}`;
- };
-
- export const brazilianDateToEnglish = (brazilianDate: string): string => {
- const date = brazilianDate || '';
- const [day, month, year] = date.split('/');
-
- return day && month && year ? `${year}-${month}-${day}` : '';
- };
-
- export const brazilianMoneyToNumber = (money: string): number => {
- const value = money?.replace(/\./gm, '').replace(/,/, '.');
-
- return value ? Number(value) : 0;
- };
-
- export default {};
|