Use strftime in sqlite instead of new date

The javascript date method was messing up the timezones.
This commit is contained in:
Brandon Presley 2022-08-18 12:08:03 +12:00
parent a85d5464be
commit 6eacddf2d0
2 changed files with 4 additions and 5 deletions

View File

@ -52,12 +52,12 @@ export default function EditSet() {
const add = useCallback(
async (set: Set) => {
const {name, reps, weight, created, unit} = set;
const {name, reps, weight, unit} = set;
const insert = `
INSERT INTO sets(name, reps, weight, created, unit)
VALUES (?,?,?,?,?)
VALUES (?,?,?,strftime('%Y-%m-%dT%H:%M:%S', 'now', 'localtime'),?)
`;
await db.executeSql(insert, [name, reps, weight, created, unit]);
await db.executeSql(insert, [name, reps, weight, unit]);
notify();
navigation.goBack();
},

View File

@ -92,7 +92,6 @@ export default function SetList() {
weight: 0,
name: '',
reps: 0,
created: new Date().toISOString(),
id: 0,
};
const [repsResult] = await db.executeSql(bestReps, [
@ -167,12 +166,12 @@ export default function SetList() {
const onAdd = useCallback(async () => {
const set: Set = {
created: new Date().toISOString(),
name: '',
id: 0,
reps: 0,
weight: 0,
unit: 'kg',
created: new Date().toISOString(),
};
navigation.navigate('EditSet', {set: nextSet || set});
}, [navigation, nextSet]);