moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

Documentation includes function filterYears but most recent version does not

Open dodtsair opened this issue 8 years ago • 2 comments

Am I missing something?

I do the following:

var momentTZ = require('moment-timezone');



var currentDate = new Date();
var currentYear = currentDate.getFullYear();
var zoneNames = momentTZ.tz.names();
var unpackedZones = [];
zoneNames.forEach(function(zoneName) {
  unpackedZones.push(momentTZ.tz.zone(zoneName));
});
var relevantZones = momentTZ.tz.filterYears(unpackedZones, currentYear);

This errors calling momentTZ.tz.filterYears because it does not exist. Was this function removed?

How do I get a list of zones and relevant information to the present?

dodtsair avatar Mar 24 '16 06:03 dodtsair

As noted at the top of the section in http://momentjs.com/timezone/docs/#/data-utilities/, these utilities are available in moment-timezone-utils.js. I think you should be able to load them for use by changing the first lines to something like this.

var momentTZ = require('moment-timezone');
require('moment-timezone/moment-timezone-utils');

These will be moved around a bit with the conversion to es6 modules in #310. What are you trying to accomplish when using filterYears, is there a way we could make this easier to use for you?

timrwood avatar Mar 24 '16 15:03 timrwood

I was trying to get a list of TZ names that are current. I didn't want a list that includes TZs that never existed or were no longer used.

dodtsair avatar Apr 12 '16 19:04 dodtsair