Fix datetime bug
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { DATA_DIRECTORY_URI_KEY } from '@/constants/Settings';
|
||||
import { StorageAccessFramework } from 'expo-file-system';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { format } from 'date-fns';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { StorageAccessFramework } from 'expo-file-system';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
interface FileEntry {
|
||||
name: string;
|
||||
@@ -22,7 +22,7 @@ interface FileInfoWithSize {
|
||||
size: number;
|
||||
}
|
||||
|
||||
function datetimeFromFilename(filename: string): string {
|
||||
function datetimeFromFilename(filename: string): Date {
|
||||
const match = filename.match(/(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)\.md$/);
|
||||
if (match) {
|
||||
const [_, year, month, day, hour, minute, second] = match;
|
||||
@@ -33,9 +33,9 @@ function datetimeFromFilename(filename: string): string {
|
||||
parseInt(hour),
|
||||
parseInt(minute),
|
||||
parseInt(second)
|
||||
).toISOString();
|
||||
);
|
||||
}
|
||||
return new Date().toISOString();
|
||||
return new Date();
|
||||
}
|
||||
|
||||
export function prettyName(uri: string | null, options: PrettyNameOptions = {}) {
|
||||
@@ -118,7 +118,7 @@ export function useFileSystem() {
|
||||
}
|
||||
markdownFiles.sort((a, b) => b.datetime.getTime() - a.datetime.getTime()); // Sort by datetime descending
|
||||
setFiles(markdownFiles);
|
||||
setDirectorySize(totalSize);
|
||||
setDirectorySize(Math.round((totalSize / 1024 / 1024) * 1000) / 1000); // Convert to MB
|
||||
} catch (error) {
|
||||
console.error('Error loading files:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user