Repository navigation
Expand file tree
/
Copy pathstyle.js
More file actions
47 lines (37 loc) · 1.35 KB
/
Copy pathstyle.js
File metadata and controls
47 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var fileName = {day: 'numeric'};
var today = new Date();
document.getElementById("date").innerHTML = today.toLocaleDateString("en-GB", options);
console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016
const date = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
const formattedDate = formatter.formatToParts(date).reduce((acc, part) => {
if (part.type === 'year' || part.type === 'month' || part.type === 'day') {
return acc + part.value;
} else {
return acc;
}
}, '');
//"DON_2010_JOE_1222022.txt".match(/DON_.+_JOE_.+\.txt/)
const fs = require("fs");
const path = require("path");
const directoryPath = "./entries"; // Directory to search
const fileNameToSearch = formattedDate.match(/.+\.html/); // Replace with the variable name
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
} else {
const foundFile = files.find(file => file === fileNameToSearch);
if (foundFile) {
console.log('File found:', foundFile);
// Send the file information back to the client
} else {
console.log('File not found.');
}
}
});