Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moment-timezone v0.5.20, the NPM package is missing data/unpacked/latest.json #638

Closed
zrecore opened this issue Jun 22, 2018 · 6 comments
Closed

Comments

@zrecore
Copy link

zrecore commented Jun 22, 2018

Heads up, installing from NPM, the moment-timezone package (0.5.20) does not ship with the data/unpacked/latest.json file, even though it's shown in this git repo.

Edit: It appears v0.5.18 and v0.5.19 NPM packages are missing the unpacked latest.json data, too.

@ellenaua
Copy link
Contributor

@zrecore it was done after this pull request
#610
do you use unpacked data?

@SeBassFox
Copy link

I'am also missing this file. I'am using that file in combination with filterLinkPack (moment-timezone-utils) to create a custom data file (restrict the years to get a smaller webpack build).
Would be helpful if this file can be available through npm.

@zrecore
Copy link
Author

zrecore commented Jul 11, 2018

A client I worked with needed the unpacked data. They've since reworked their time zone data packer script to manually unpack the packed data and manually reassemble what they need.

@Tanner-Stults
Copy link

Tanner-Stults commented Dec 12, 2018

As far as I can tell, without the unpacked data subseting becomes more difficult, requiring the developers to unpack and unlink the data. While you can unpack the packed/latest.json file (like @zrecore mentioned) vai moment.tz.unpack, there doesn't seem to be a provided utility function to unlink the existing links in the packed latest.json file. Merely unpacking the provided packed/latest.json file isn't enough to recreated the unpacked version, you also have to unlink all of the links. Providing the unpacked file or a utility function that does the unlinking will allow devs to subset properly.

For reference, this is how one might work around not having access to the unpacked data:

const packedLatest = require('moment-timezone/data/packed/latest.json');

function unpackAndUnlink(latest) {
    const unpacked = {
        ...latest,
        zones: latest.zones.map(moment.tz.unpack),
        links: []
    };

    latest.links.forEach(link => {
        const [ leadTzName, alias ] = link.split('|');
        const leadTzData = unpacked.zones.find(zone => zone.name === leadTzName);

        unpacked.zones.push({
            ...leadTzData,
            name: alias
        });
    });

    return unpacked;
}

const unpackedLatest = unpackAndUnlink(packedLatest);

Clearly, parsing through the link strings to unlink the existing links is not ideal, and could be provided by moment-timezone-utils.js. Perhaps there is a better way that I am missing.

@palashkaria
Copy link

Hey,
I'm facing this issue, & I need the original unpacked file, because we are not adding countries to zones while packing. This leads to loss of array order info when unpacking.
Please add this back if possible.

@gilmoreorless
Copy link
Member

With the full 64-bit data range, the unpacked JSON file is at least 11MB in size. Given that some people aren't happy with a package size of just under 1MB (#999), I can't see the unpacked file being included any time soon.

@gilmoreorless gilmoreorless closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants