Closed slavap closed 6 years ago
I've fixed it manually in my project:
exports.default = function (jsJoda) {
jsJoda.ZoneRulesProvider.getRules = _MomentZoneRulesProvider.MomentZoneRulesProvider.getRules;
jsJoda.ZoneRulesProvider.getAvailableZoneIds = _MomentZoneRulesProvider.MomentZoneRulesProvider.getAvailableZoneIds;
/*ADDED>>>*/ jsJoda.ZoneRulesProvider.TZDB = _latest2.default;
(0, _systemDefaultZone2.default)(jsJoda.ZoneId);
return jsJoda;
};
Then it's possible to call:
moment.tz.load(JSJoda.ZoneRulesProvider.TZDB);
and get moment.tz working based on joda's IANA database.
Hello @slavap
thx for using js-joda and your feedback.
I guess your use case is, that you need moment and js-joda in the browser and you want save data transferred to the client, correct ? just for curiosity, what do you miss in js-joda-timezone what just moment.tz has?
Well, anyway, i agree that re-using the tzdb data is a valid use case and we can export it for further use.
BUT, the format of tzdb data is compatible to moment.tz.load()
by accident and this might change in the future, because we are missing some information in the "moment style" data.
So i could mark the export as private (eg jsJoda.ZoneRulesProvider._TZDB
), but there is no guarantee that the format change in a next major update. Would that help ?
@pithu one of the useful functions is moment.tz.guess(), which can use timezone database for searching appropriate timezone if browser does not report it. Also some external code depends on moment.tz and I don’t want to port it to joda. If it’s possible, please preserve compatibility with moment.tz database even if extending joda’s db, because it will be too painful to load two similar timezone databases. Private export should be fine, thank you.
@slavap, i just released a new version, can you please verify if it worx as expected. var name is JSJoda.ZoneRulesProvider._TZDB
@pithu Thanks, it's working fine.
Add function/property to JSJodaTimezone to allow getting packed json zone database, then it will be possible using it with moment.tz.load()