moment / moment-timezone

Timezone support for moment.js
momentjs.com/timezone
MIT License
3.82k stars 837 forks source link

Documentation includes function filterYears but most recent version does not #319

Closed dodtsair closed 1 year ago

dodtsair commented 8 years ago

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?

timrwood commented 8 years ago

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?

dodtsair commented 8 years ago

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.