12345678910111213141516171819 |
- import { PixelRatio } from 'react-native';
- const fontScale = PixelRatio.getFontScale();
- export const getFontSize = (size: number) => size / fontScale;
- export const getYears = (date: string): number => {
- const birthDate = new Date(date);
- const today = new Date();
- let age = today.getFullYear() - birthDate.getFullYear();
- const monthDifference = today.getMonth() - birthDate.getMonth();
- const dayDifference = today.getDate() - birthDate.getDate();
- if (monthDifference < 0 || (monthDifference === 0 && dayDifference < 0)) {
- age--;
- }
- return age;
- };
|