25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
1.1 KiB

  1. import dates from '../date/dates';
  2. export const registryRemoveMask = (cnpj: string): string => cnpj?.replace(/\D/gm, '') || '';
  3. export const competenceDescriptionToDate = (competenceDescription: string): string => {
  4. const [monthDescription, year] = competenceDescription.split('de');
  5. const month = dates.find(date => {
  6. const dateDescriptionNormalized = date.description.toLocaleLowerCase('en-US').trim();
  7. const monthDescriptionNormalized = monthDescription.toLocaleLowerCase('en-US').trim();
  8. return dateDescriptionNormalized === monthDescriptionNormalized;
  9. })?.value;
  10. const monthFormatted = `00${month}`.slice(-2);
  11. return `${monthFormatted}/${year.trim()}`;
  12. };
  13. export const brazilianDateToEnglish = (brazilianDate: string): string => {
  14. const date = brazilianDate || '';
  15. const [day, month, year] = date.split('/');
  16. return day && month && year ? `${year}-${month}-${day}` : '';
  17. };
  18. export const brazilianMoneyToNumber = (money: string): number => {
  19. const value = money?.replace(/\./gm, '').replace(/,/, '.');
  20. return value ? Number(value) : 0;
  21. };
  22. export default {};