File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module.exports = function(grunt) {
18
18
build : {
19
19
'moment-timezone-with-data' : true ,
20
20
'moment-timezone-with-data-1970-2030' : [ 1970 , 2030 ] ,
21
- 'moment-timezone-with-data-2012-2022' : [ 2012 , 2022 ] ,
21
+ 'moment-timezone-with-data-2012-2022' : [ 2012 , 2022 , 'warn' ] ,
22
22
'moment-timezone-with-data-10-year-range' : [ currentYear - 5 , currentYear + 5 ]
23
23
} ,
24
24
Original file line number Diff line number Diff line change 3
3
var tz = require ( '../moment-timezone-utils' ) . tz ,
4
4
groupLeaders = require ( './group-leaders.json' ) ;
5
5
6
+ // A cut-down version of `deprecate()` from core moment.js
7
+ function staleDataWarning ( ) {
8
+ if ( moment . suppressDeprecationWarnings === false &&
9
+ ( typeof console !== 'undefined' ) && console . warn ) {
10
+ console . warn (
11
+ 'Deprecation warning: ' +
12
+ 'Moment Timezone has been loaded from a file containing data from 2012 to 2022 only. ' +
13
+ 'This file is out of date and may be removed in a future release. ' +
14
+ 'Dates and times for the current year might be incorrect.'
15
+ ) ;
16
+ }
17
+ }
18
+
6
19
module . exports = function ( grunt ) {
7
20
grunt . registerMultiTask ( 'build' , 'Build minified versions with data included.' , function ( ) {
8
21
var dest = 'builds/' + this . target + '.js' ,
@@ -24,6 +37,11 @@ module.exports = function (grunt) {
24
37
data = data . split ( '\n' ) . join ( '\n\t' ) ;
25
38
data = 'loadData(' + data + ');\n' ;
26
39
40
+ if ( this . data && this . data [ 2 ] === 'warn' ) {
41
+ data += '\n\t' + staleDataWarning . toString ( ) . split ( '\n' ) . join ( '\n\t' )
42
+ + '\n\tstaleDataWarning();'
43
+ }
44
+
27
45
source = source . replace ( '// INJECT DATA' , data ) ;
28
46
29
47
grunt . file . write ( dest , source ) ;
You can’t perform that action at this time.
0 commit comments