Skip to content

Commit

Permalink
Replace date-fns with dayjs for date-formatting to reduce bundle size…
Browse files Browse the repository at this point in the history
… and improved the parse format
  • Loading branch information
Theofilos committed Dec 26, 2020
1 parent 99897a9 commit 38ae3f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@react-native-community/async-storage": "^1.12.1",
"@react-native-community/masked-view": "^0.1.10",
"date-fns": "^2.16.1",
"dayjs": "^1.9.7",
"native-base": "^2.15.0",
"react": "17.0.1",
"react-native": "0.63.4",
Expand Down
6 changes: 3 additions & 3 deletions src/screens/tabs/HistoryTab.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {PureComponent} from 'react';
import {StatusBar, StyleSheet, Text, View} from 'react-native';
import Timeline from 'react-native-timeline-flatlist';
import format from 'date-fns/format';
import dayjs from 'dayjs';

import {getAllRecords} from '../../db/asyncStorageProvider';

Expand Down Expand Up @@ -42,8 +42,8 @@ export default class HistoryTab extends PureComponent {
fillTimeline = (data: [string, (string | null)][]) => {
const timelineArray = data.map((call, index) => {
const timestamp = Number(call[0]);
const dateString = (format(new Date(timestamp), 'dd/MM')).toString();
const timeString = (format(new Date(timestamp), 'hh:mm')).toString();
const dateString = dayjs(new Date(timestamp)).format('DD/MM');
const timeString = dayjs(new Date(timestamp)).format('HH:mm');

const phone = JSON.parse(call[1] as string).phone;
const carrier = JSON.parse(call[1] as string).carrier;
Expand Down

0 comments on commit 38ae3f4

Please sign in to comment.