{"id":21224086,"url":"https://github.com/kodie/date-shortcode","last_synced_at":"2025-07-10T14:31:18.109Z","repository":{"id":80332551,"uuid":"123501646","full_name":"kodie/date-shortcode","owner":"kodie","description":"A small and simple date shortcode library.","archived":false,"fork":false,"pushed_at":"2023-01-06T19:59:12.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T22:14:52.082Z","etag":null,"topics":["date","day","hour","minute","month","parse","second","shortcode","string","strip","test","time","year"],"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/kodie.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-01T22:52:07.000Z","updated_at":"2020-09-27T01:21:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"6d687e90-0df4-48c6-9bba-f7e32c52ad09","html_url":"https://github.com/kodie/date-shortcode","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"53c72f32cd2495ef6cf22d22b04231b24e8ac498"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fdate-shortcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fdate-shortcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fdate-shortcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kodie%2Fdate-shortcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kodie","download_url":"https://codeload.github.com/kodie/date-shortcode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225640771,"owners_count":17501018,"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":["date","day","hour","minute","month","parse","second","shortcode","string","strip","test","time","year"],"created_at":"2024-11-20T22:54:58.790Z","updated_at":"2024-11-20T22:54:59.418Z","avatar_url":"https://github.com/kodie.png","language":"JavaScript","readme":"# date-shortcode\n\n[![npm package version](https://img.shields.io/npm/v/date-shortcode.svg?style=flat-square)](https://www.npmjs.com/package/date-shortcode)\n[![Travis build status](https://img.shields.io/travis/kodie/date-shortcode.svg?style=flat-square)](https://travis-ci.org/kodie/date-shortcode)\n[![npm package downloads](https://img.shields.io/npm/dt/date-shortcode.svg?style=flat-square)](https://www.npmjs.com/package/date-shortcode)\n[![code style](https://img.shields.io/badge/code_style-standard-yellow.svg?style=flat-square)](https://github.com/standard/standard)\n[![license](https://img.shields.io/github/license/kodie/date-shortcode.svg?style=flat-square)](license.md)\n\nA small and simple date shortcode library.\n\n## Installation\n\n```shell\nnpm install --save date-shortcode\n```\n\n## Usage\n\n```javascript\nconst dateShortcode = require('date-shortcode')\n\nvar str = 'It is {h:mm A} on the {Do} day of {MMMM YYYY}.'\ndateShortcode.parse(str)\n//=\u003e 'It is 3:26 PM on the 1st day of March 2018.'\n```\n\n### API\n\n#### codes([ date ])\n\nReturns an `Array` containing all possible codes, their current values, descriptions, and examples.\n\n##### Parameters\n\n###### date (`String`/`Date`)\n\n*Optional*\n\nA Date object or a String to pass to a Date object. Defaults to now.\n\n##### Example\n\n```javascript\ndateShortcode.codes('2007-06-12')\n//=\u003e [ { code: 'MMMM',\n//=\u003e     value: 'June',\n//=\u003e     description: 'Month',\n//=\u003e     example: 'January February ... November December' },\n//=\u003e   { code: 'MMM',\n//=\u003e     value: 'Jun',\n//=\u003e     description: 'Month (3 characters)',\n//=\u003e     example: 'Jan Feb ... Nov Dec' },\n//=\u003e   { code: 'MM',\n//=\u003e     value: '06',\n//=\u003e   ...\n```\n\n#### config(conf)\n\nChange configuration parameters. Returns an instance of `date-shortcode`.\n\n##### Parameters\n\n###### conf (`Object`)\n\nThe configuration parameters to change.\n\n##### Example\n\n```javascript\nvar dateShortcodeConfig = {\n  openTag: '\\\\[',\n  closeTag: '\\\\]'\n}\n\nconst dateShortcode = require('date-shortcode').config(dateShortcodeConfig)\n\nvar str = 'It\\'s the [wo] week of \\'[YY]!'\ndateShortcode.parse(str)\n//=\u003e \"It's the 9th week of '18!\"\n```\n\n\n#### parse(str, [ date ])\n\nParse a String with [date shortcodes](#shortcodes) in it. Returns a String.\n\n##### Parameters\n\n###### str (`String`)\n\nThe String to do the parsing on.\n\n###### date (`String`/`Date`)\n\n*Optional*\n\nA Date object or a String to pass to a Date object. Defaults to now.\n\n##### Example\n\n```javascript\nvar str = 'Current date: {MMMM Do, YYYY}'\ndateShortcode.parse(str, '2006-10-09')\n//=\u003e 'Current date: October 9th, 2006'\n```\n\n\n#### strip(str)\n\nStrip [date shortcodes](#shortcodes) from a string.\n\n##### Parameters\n\n###### str (`String`)\n\nThe string to strip date shortcodes from.\n\n##### Example\n\n```javascript\nvar str = 'It is {h:mm A} on the {Do} day of {MMMM YYYY}.'\ndateShortcode.strip(str)\n//=\u003e 'It is  on the  day of .'\n```\n\n\n#### test(str1, str2)\n\nTest if two Strings would be the same without [date shortcodes](#shortcodes).\n\n##### Parameters\n\n###### str1 (`String`)\n\nFirst string to test.\n\n###### str2 (`String`)\n\nSecond string to test.\n\n##### Example\n\n```javascript\nvar str1 = 'It is {h:mm A} on the {Do} day of {MMMM YYYY}.'\nvar str2 = 'It is 3:26 PM on the 1st day of March 2018.'\ndateShortcode.test(str1, str2)\n//=\u003e true\n\nvar str3 = 'This string is nothing like the rest.'\ndateShortcode.test(str1, str3)\n//=\u003e false\n```\n\n##### Note\n\nThis function will return `true` if the two supplied strings are very similar.\n\nFor example:\n\n```javascript\nvar str1 = 'Hey, it\\'s {h}!'\nvar str2 = 'Hey, it\\'s Bob!'\ndateShortcode.test(str1, str2)\n//=\u003e true\n\nvar str1 = 'Hey, it\\'s {h} o\\'clock!'\nvar str2 = 'Hey, it\\'s Bob Saget!'\ndateShortcode.test(str1, str2)\n//=\u003e false\n```\n\n### Shortcodes\n\nThese are the codes that you can use with the above functions. They are case-sensitive. You may use a combination of multiple codes as well as non-shortcode characters in a set of brackets (i.e `{H:mmA} {M/D/YY}`).\n\n| Description                    | Code  | Example                                  |\n|--------------------------------|-------|------------------------------------------|\n| Month                          | MMMM  | January February ... November December   |\n| Month (3 characters)           | MMM   | Jan Feb ... Nov Dec                      |\n| Month Number (Padded)          | MM    | 01 02 ... 11 12                          |\n| Month Number (Suffixed)        | Mo    | 1st 2nd ... 11th 12th                    |\n| Month Number                   | M     | 1 2 ... 11 12                            |\n| Quarter (Suffixed)             | Qo    | 1st 2nd 3rd 4th                          |\n| Quarter                        | Q     | 1 2 3 4                                  |\n| Day of Year (Padded)           | DDDD  | 001 002 ... 364 365                      |\n| Day of Year (Suffixed)         | DDDo  | 1st 2nd ... 364th 365th                  |\n| Day of Year                    | DDD   | 1 2 ... 364 365                          |\n| Day of Month (Padded)          | DD    | 01 02 ... 30 31                          |\n| Day of Month (Suffixed)        | Do    | 1st 2nd ... 30th 31st                    |\n| Day of Month                   | D     | 1 2 ... 30 31                            |\n| Day of Week                    | dddd  | Sunday Monday ... Friday Saturday        |\n| Day of Week (3 characters)     | ddd   | Sun Mon ... Fri Sat                      |\n| Day of Week (2 characters)     | dd    | Su Mo ... Fr Sa                          |\n| Day of Week Number (Suffixed)  | do    | 0th 1st ... 5th 6th                      |\n| Day of Week Number             | d     | 0 1 ... 5 6                              |\n| Week of Year (Padded)          | ww    | 01 02 ... 52 53                          |\n| Week of Year (Suffixed)        | wo    | 1st 2nd ... 52nd 53rd                    |\n| Week of Year                   | w     | 1 2 ... 52 53                            |\n| Year                           | YYYY  | 1970 1971 ... 2029 2030                  |\n| Year (2 characters)            | YY    | 70 71 ... 29 30                          |\n| AM/PM                          | A     | AM PM                                    |\n| am/pm                          | a     | am pm                                    |\n| Hour (24 hours/Padded)         | kk    | 01 02 ... 23 24                          |\n| Hour (24 hours)                | k     | 1 2 ... 23 24                            |\n| Hour (12 hours/Padded)         | hh    | 01 02 ... 11 12                          |\n| Hour (12 hours)                | h     | 1 2 ... 11 12                            |\n| Hour (24 hours/0-Index/Padded) | HH    | 00 01 ... 22 23                          |\n| Hour (24 hours/0-Index)        | H     | 0 1 ... 22 23                            |\n| Minute (Padded)                | mm    | 00 01 ... 58 59                          |\n| Minute                         | m     | 0 1 ... 58 59                            |\n| Second (Padded)                | ss    | 00 01 ... 58 59                          |\n| Second                         | s     | 0 1 ... 58 59                            |\n\n## License\nMIT. See the [license.md file](license.md) for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fdate-shortcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkodie%2Fdate-shortcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkodie%2Fdate-shortcode/lists"}