File size: 1,733 Bytes
cd9ae48
 
 
 
 
 
 
 
b14f8d1
cd9ae48
 
 
 
 
 
 
 
 
 
 
b14f8d1
cd9ae48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b14f8d1
cd9ae48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'

// Safe Global Date Format Overrides
const originalToLocaleDateString = Date.prototype.toLocaleDateString;

Date.prototype.toLocaleDateString = function() {
  if (isNaN(this.getTime())) return 'N/A';
  try {
    const day = this.getDate();
    const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
    const year = this.getFullYear();
    return `${day}-${month}-${year}`;
  } catch {
    return 'N/A';
  }
};

Date.prototype.toLocaleString = function() {
  if (isNaN(this.getTime())) return 'N/A';
  try {
    const day = this.getDate();
    const month = originalToLocaleDateString.call(this, 'en-US', { month: 'short' }).toUpperCase();
    const year = this.getFullYear();
    
    let hours = this.getHours();
    const minutes = this.getMinutes().toString().padStart(2, '0');
    const ampm = hours >= 12 ? 'PM' : 'AM';
    hours = hours % 12;
    hours = hours ? hours : 12; 
    const strTime = `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
    
    return `${day}-${month}-${year} ${strTime}`;
  } catch {
    return 'N/A';
  }
};

Date.prototype.toLocaleTimeString = function() {
  if (isNaN(this.getTime())) return 'N/A';
  try {
    let hours = this.getHours();
    const minutes = this.getMinutes().toString().padStart(2, '0');
    const ampm = hours >= 12 ? 'PM' : 'AM';
    hours = hours % 12;
    hours = hours ? hours : 12; 
    return `${hours.toString().padStart(2, '0')}:${minutes} ${ampm}`;
  } catch {
    return 'N/A';
  }
};

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <App />
  </StrictMode>,
)