{"id":19400402,"url":"https://github.com/smartin85/moment-immutable","last_synced_at":"2025-04-24T06:32:57.560Z","repository":{"id":37602454,"uuid":"81758497","full_name":"smartin85/moment-immutable","owner":"smartin85","description":"Make moment.js immutable (moments and durations)","archived":false,"fork":false,"pushed_at":"2023-01-27T13:26:06.000Z","size":341,"stargazers_count":8,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T18:19:58.715Z","etag":null,"topics":["duration","immutable","momentjs","plugin","react"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartin85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["smartin85"],"custom":["https://www.buymeacoffee.com/smartin"]}},"created_at":"2017-02-12T21:27:23.000Z","updated_at":"2024-09-10T18:39:31.000Z","dependencies_parsed_at":"2023-02-06T12:47:05.239Z","dependency_job_id":null,"html_url":"https://github.com/smartin85/moment-immutable","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fmoment-immutable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fmoment-immutable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fmoment-immutable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartin85%2Fmoment-immutable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartin85","download_url":"https://codeload.github.com/smartin85/moment-immutable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250578985,"owners_count":21453399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["duration","immutable","momentjs","plugin","react"],"created_at":"2024-11-10T11:14:01.564Z","updated_at":"2025-04-24T06:32:56.384Z","avatar_url":"https://github.com/smartin85.png","language":"JavaScript","funding_links":["https://github.com/sponsors/smartin85","https://www.buymeacoffee.com/smartin"],"categories":[],"sub_categories":[],"readme":"# moment-immutable\n[![MIT License][license-image]][license-url] \n[![npm version][npm-image]][npm-url]\n[![npm downloads][downloads-image]][npm-url]\n[![Build Status][azure-pipeline-image]][azure-pipeline-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n\n[![Buy me a coffee][buy-me-a-coffee-image]][buy-me-a-coffee-url]\n\nMake moment.js immutable (moments and durations)\n\n## Getting Started\nmoment-immutable can be included in your app by different ways:\n\n### Node.js\nmoment-immutable can be installed with npm and required into a script:\n```\nnpm install --save moment-immutable\n```\n```js\nvar moment = require('moment');\nrequire('moment-immutable');\n```\n\n\n### Browser\nJust include the momentjs script, all your other moment.js-plugins and then the moment-immutable script:\n```html\n\u003cscript src=\"moment.js\"\u003e\u003c/script\u003e\n\u003c!-- All the other cool moment.js-plugins --\u003e\n\u003cscript src=\"moment-immutable.min.js\"\u003e\u003c/script\u003e\n```\n\n### Browser with Require.js\n```js\ndefine([\"moment\", \"moment-immutable\"], function (moment) {\n    // you probably won´t need a reference to moment-immutable istself, so include it last\n});\n```\n\n### Bower\n```\nbower install --save moment-immutable\n```\n\n## Working without moment-immutable\n\n```js\nvar january1st = moment(\"2017-01-01\");\nvar february1st = january1st.add(1, \"month\");\n\njanuary1st.format();    // \"2017-02-01T00:00:00+01:00\" - damn\nfebruary1st.format();   // \"2017-02-01T00:00:00+01:00\"\n```\n\n## Working with moment-immutable\n```js\nvar january1st = moment(\"2017-01-01\");\nvar february1st = january1st.add(1, \"month\");\n\njanuary1st.format();    // \"2017-01-01T00:00:00+01:00\" - yeah\nfebruary1st.format();   // \"2017-02-01T00:00:00+01:00\"\n```\n\n## Converting mutable methods of other plugins to immutable methods\nBy default moment-immutable is aware of all the mutable methods of moment.js (moments and durations) and moment-timezone.  \nFor converting mutable methods of other plugins to immutable methods you can do this:\n```js\n// If it is a method on moment-objects:\nmoment.immutable.addMomentMutable('period', 1); // makes the period-function immutable if it has at least 1 parameter\n\n// If it is a method on a moment-duration-object\nmoment.immutable.addDurationMutable('set', 0);  // makes the set-function immutable\n```\n\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat\n[license-url]: LICENSE\n\n[npm-image]: https://badge.fury.io/js/moment-immutable.svg\n[npm-url]: https://www.npmjs.com/package/moment-immutable\n\n[downloads-image]: https://img.shields.io/npm/dt/moment-immutable.svg\n\n[coveralls-image]: https://coveralls.io/repos/github/smartin85/moment-immutable/badge.svg\n[coveralls-url]: https://coveralls.io/github/smartin85/moment-immutable\n\n[snyk-image]: https://snyk.io/test/github/smartin85/moment-immutable/badge.svg\n[snyk-url]: https://snyk.io/test/github/smartin85/moment-immutable\n\n[azure-pipeline-image]: https://dev.azure.com/smartin85/moment-immutable/_apis/build/status/smartin85.moment-immutable?branchName=master\n[azure-pipeline-url]: https://dev.azure.com/smartin85/moment-immutable/_build/latest?definitionId=2\u0026branchName=master\n\n[buy-me-a-coffee-image]: https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png\n[buy-me-a-coffee-url]: https://www.buymeacoffee.com/smartin","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartin85%2Fmoment-immutable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartin85%2Fmoment-immutable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartin85%2Fmoment-immutable/lists"}