@@ -5,7 +5,6 @@ var SendComment = null;
5
5
const preloader_view = document . querySelector ( "#bloggit-preloader" ) ;
6
6
let current_url = window . location . href
7
7
let api_key = bloggit_conf . api_key
8
-
9
8
let cont_rend = bloggit_conf . cont_rend
10
9
if ( bloggit_conf . header ) {
11
10
var header_type = bloggit_conf . header . type
@@ -65,29 +64,23 @@ var SendComment = null;
65
64
}
66
65
}
67
66
68
-
69
-
70
67
function convert_datetime ( param ) {
71
- const dateComponents = param . match ( / ( \d { 4 } ) - ( \d { 2 } ) - ( \d { 2 } ) T ( \d { 2 } ) : ( \d { 2 } ) : ( \d { 2 } ) / ) ;
72
-
73
- const year = parseInt ( dateComponents [ 1 ] ) ;
74
- const month = parseInt ( dateComponents [ 2 ] ) - 1 ;
75
- const day = parseInt ( dateComponents [ 3 ] ) ;
76
-
77
- // Create a JavaScript Date object without considering the timezone
78
- const date = new Date ( year , month , day ) ;
79
-
80
- const time = new Date ( param ) ;
81
-
82
- // Get the hours, minutes, and seconds
83
- const hours = time . getHours ( ) ;
84
- const minutes = time . getMinutes ( ) ;
85
- const seconds = time . getSeconds ( ) ;
86
-
87
- let __time__ = `${ hours } :${ minutes } :${ seconds } ` ;
88
-
89
- // Format the date as "Month Day, Year"
90
- return date . toLocaleDateString ( 'en-US' , { year : 'numeric' , month : 'long' , day : 'numeric' } ) . toString ( ) //+ " ; " + __time__;
68
+ const originalDate = new Date ( param ) ;
69
+ const userTimeZone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ;
70
+
71
+ const options = {
72
+ timeZone : userTimeZone ,
73
+ year : 'numeric' ,
74
+ month : 'short' ,
75
+ day : 'numeric' ,
76
+ hour : 'numeric' ,
77
+ minute : 'numeric' ,
78
+ second : 'numeric' ,
79
+ hour12 : false
80
+ } ;
81
+
82
+ const convertedDate = new Intl . DateTimeFormat ( 'en-US' , options ) . format ( originalDate ) ;
83
+ return convertedDate
91
84
}
92
85
93
86
function strip_tags ( param ) {
@@ -141,7 +134,6 @@ fetch(`http://127.0.0.1:8000/posts/api/${api_key}?url=${current_url}&cont_rend=$
141
134
}
142
135
143
136
// Set the attributes of the link element
144
-
145
137
bloggit_data = ( data [ "posts" ] !== undefined ) ? data [ "posts" ] : data [ "post" ] ;
146
138
147
139
0 commit comments