File tree Expand file tree Collapse file tree 6 files changed +55
-2
lines changed Expand file tree Collapse file tree 6 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,12 @@ import $ from 'jquery';
2
2
3
3
var date = new Date ( ) ;
4
4
var currentTimestamp = date . toISOString ( ) . replace ( / ^ ( .* ) ( \. \d + ) ( Z ) / , '$1$3' ) ; // 2023-01-01T12:34:56Z
5
- var currentTime = date . toISOString ( ) . replace ( / ( ^ .* T ) ( .* ) ( Z ) / , '$2' ) + '084216' ; // 12:34:56.000084216
6
5
6
+ // Microsecond offset appended to the current time string for formatting purposes
7
+ const MICROSECOND_OFFSET = '084216' ;
8
+
9
+ var currentTime =
10
+ date . toISOString ( ) . replace ( / ( ^ .* T ) ( .* ) ( Z ) / , '$2' ) + MICROSECOND_OFFSET ; // 12:34:56.000084216
7
11
function currentDate ( offset = 0 , trimTime = false ) {
8
12
let outputDate = new Date ( date ) ;
9
13
outputDate . setDate ( outputDate . getDate ( ) + offset ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ Datetime Components
3
+ ----------------------------------------------
4
+ */
5
+
6
+ .current-timestamp ,
7
+ .current-date ,
8
+ .current-time ,
9
+ .enterprise-eol-date {
10
+ color : $current-timestamp-color ;
11
+ display : inline-block ;
12
+ font-family : $proxima ;
13
+ white-space : nowrap ;
14
+ }
15
+
16
+ .nowrap {
17
+ white-space : nowrap ;
18
+ }
Original file line number Diff line number Diff line change 23
23
" layouts/syntax-highlighting" ,
24
24
" layouts/algolia-search-overrides" ,
25
25
" layouts/landing" ,
26
+ " layouts/datetime" ,
26
27
" layouts/error-page" ,
27
28
" layouts/footer-widgets" ,
28
29
" layouts/modals" ,
Original file line number Diff line number Diff line change @@ -203,6 +203,12 @@ $article-btn-text-hover: $g20-white;
203
203
$article-nav-icon-bg : $g5-pepper ;
204
204
$article-nav-acct-bg : $g3-castle ;
205
205
206
+ // Datetime shortcode colors
207
+ $current-timestamp-color : $g15-platinum ;
208
+ $current-date-color : $g15-platinum ;
209
+ $current-time-color : $g15-platinum ;
210
+ $enterprise-eol-date-color : $g15-platinum ;
211
+
206
212
// Error Page Colors
207
213
$error-page-btn : $b-pool ;
208
214
$error-page-btn-text : $g20-white ;
Original file line number Diff line number Diff line change @@ -203,6 +203,12 @@ $article-btn-text-hover: $g20-white !default;
203
203
$article-nav-icon-bg : $g6-smoke !default ;
204
204
$article-nav-acct-bg : $g5-pepper !default ;
205
205
206
+ // Datetime Colors
207
+ $current-timestamp-color : $article-text !default ;
208
+ $current-date-color : $article-text !default ;
209
+ $current-time-color : $article-text !default ;
210
+ $enterprise-eol-date-color : $article-text !default ;
211
+
206
212
// Error Page Colors
207
213
$error-page-btn : $b-pool !default ;
208
214
$error-page-btn-text : $g20-white !default ;
Original file line number Diff line number Diff line change @@ -1351,4 +1351,22 @@ and all the rows with the `hum` field will be in another.
1351
1351
| 2022-01-01T10:00:00Z | home | Living Room | temp | 21.8 |
1352
1352
1353
1353
{{% /tab-content %}}
1354
- {{< /tabs-wrapper >}}
1354
+ {{< /tabs-wrapper >}}
1355
+
1356
+ ## datetime/current-timestamp shortcode
1357
+
1358
+ ### Default usage
1359
+
1360
+ {{< datetime/current-timestamp >}}
1361
+
1362
+ ### Format YYYY-MM-DD HH:mm: ss
1363
+
1364
+ {{< datetime/current-timestamp format="YYYY-MM-DD HH:mm: ss " >}}
1365
+
1366
+ ### Format with UTC timezone
1367
+
1368
+ {{< datetime/current-timestamp format="YYYY-MM-DD HH:mm: ss " timezone="UTC" >}}
1369
+
1370
+ ### Format with America/New_York timezone
1371
+
1372
+ {{< datetime/current-timestamp format="YYYY-MM-DD HH:mm: ss " timezone="America/New_York" >}}
You can’t perform that action at this time.
0 commit comments