File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11import assert from 'assert' ;
2+ import moment from 'moment-timezone' ;
23import type Hexo from './index' ;
34
45export = ( ctx : Hexo ) : void => {
@@ -24,5 +25,24 @@ export = (ctx: Hexo): void => {
2425 if ( config . root . trim ( ) . length <= 0 ) {
2526 throw new TypeError ( 'Invalid config detected: "root" should not be empty!' ) ;
2627 }
27- } ;
2828
29+ if ( ! config . timezone ) {
30+ log . warn ( 'No timezone setting detected! Using the default timezone UTC.' ) ;
31+ config . timezone = 'UTC' ;
32+ } else {
33+ const configTimezone = moment . tz . zone ( config . timezone ) ;
34+ if ( ! configTimezone ) {
35+ log . warn (
36+ `Invalid timezone setting detected! "${ config . timezone } " is not a valid timezone. Using the default timezone UTC.`
37+ ) ;
38+ config . timezone = 'UTC' ;
39+ } else {
40+ const machineTimezone = moment . tz . guess ( ) ;
41+ if ( configTimezone . name !== machineTimezone ) {
42+ log . warn (
43+ `The timezone "${ config . timezone } " setting is different from your machine timezone "${ machineTimezone } ". Make sure this is intended.`
44+ ) ;
45+ }
46+ }
47+ }
48+ } ;
You can’t perform that action at this time.
0 commit comments