larxius commited on
Commit
cd9ae48
·
verified ·
1 Parent(s): 7214c09

Update frontend/src/main.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/main.jsx +59 -44
frontend/src/main.jsx CHANGED
@@ -1,44 +1,59 @@
1
-
2
- import { StrictMode } from 'react'
3
- import { createRoot } from 'react-dom/client'
4
- import './index.css'
5
- import App from './App.jsx'
6
-
7
- // Global Date Format Override to enforce Day-MONTH-Year (e.g. 7-JAN-2026)
8
- const originalToLocaleDateString = Date.prototype.toLocaleDateString;
9
-
10
- Date.prototype.toLocaleDateString = function() {
11
- const day = this.getDate();
12
- const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
13
- const year = this.getFullYear();
14
- return `${day}-${month}-${year}`;
15
- };
16
-
17
- Date.prototype.toLocaleString = function() {
18
- const day = this.getDate();
19
- const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
20
- const year = this.getFullYear();
21
-
22
- let hours = this.getHours();
23
- const minutes = this.getMinutes().toString().padStart(2, '0');
24
- const ampm = hours >= 12 ? 'PM' : 'AM';
25
- hours = hours % 12;
26
- hours = hours ? hours : 12;
27
- const strTime = `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
28
-
29
- return `${day}-${month}-${year} ${strTime}`;
30
- };
31
-
32
- Date.prototype.toLocaleTimeString = function() {
33
- let hours = this.getHours();
34
- const minutes = this.getMinutes().toString().padStart(2, '0');
35
- const ampm = hours >= 12 ? 'PM' : 'AM';
36
- hours = hours % 12;
37
- hours = hours ? hours : 12;
38
- return `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
39
- };
40
- createRoot(document.getElementById('root')).render(
41
- <StrictMode>
42
- <App />
43
- </StrictMode>,
44
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import './index.css'
4
+ import App from './App.jsx'
5
+
6
+ // Safe Global Date Format Overrides
7
+ const originalToLocaleDateString = Date.prototype.toLocaleDateString;
8
+
9
+ Date.prototype.toLocaleDateString = function(...args) {
10
+ if (isNaN(this.getTime())) return 'N/A';
11
+ try {
12
+ const day = this.getDate();
13
+ const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
14
+ const year = this.getFullYear();
15
+ return `${day}-${month}-${year}`;
16
+ } catch {
17
+ return 'N/A';
18
+ }
19
+ };
20
+
21
+ Date.prototype.toLocaleString = function(...args) {
22
+ if (isNaN(this.getTime())) return 'N/A';
23
+ try {
24
+ const day = this.getDate();
25
+ const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
26
+ const year = this.getFullYear();
27
+
28
+ let hours = this.getHours();
29
+ const minutes = this.getMinutes().toString().padStart(2, '0');
30
+ const ampm = hours >= 12 ? 'PM' : 'AM';
31
+ hours = hours % 12;
32
+ hours = hours ? hours : 12;
33
+ const strTime = `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
34
+
35
+ return `${day}-${month}-${year} ${strTime}`;
36
+ } catch {
37
+ return 'N/A';
38
+ }
39
+ };
40
+
41
+ Date.prototype.toLocaleTimeString = function(...args) {
42
+ if (isNaN(this.getTime())) return 'N/A';
43
+ try {
44
+ let hours = this.getHours();
45
+ const minutes = this.getMinutes().toString().padStart(2, '0');
46
+ const ampm = hours >= 12 ? 'PM' : 'AM';
47
+ hours = hours % 12;
48
+ hours = hours ? hours : 12;
49
+ return `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
50
+ } catch {
51
+ return 'N/A';
52
+ }
53
+ };
54
+
55
+ createRoot(document.getElementById('root')).render(
56
+ <StrictMode>
57
+ <App />
58
+ </StrictMode>,
59
+ )