{"library":"moment-guess","title":"moment-guess","description":"A utility package for guessing a date string's format and outputting it as either moment.js format tokens or strftime format tokens. Current version 1.2.4. It relies on moment.js and date-and-time parsers to tokenize input, then applies refiners and assigners to produce the best guess. Useful for developers who need to reverse-engineer a date format from an example string. Unlike other date detection libraries, it supports moment.js and strftime output and handles ambiguous input by returning all possible matches. The package is maintained but has low release cadence.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install moment-guess"],"cli":null},"imports":["const guessFormat = require('moment-guess')","const guessFormat = require('moment-guess')","const guessFormat = require('moment-guess').default ?? require('moment-guess')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const guessFormat = require('moment-guess');\n\n// Default moment format\ntry {\n  console.log(guessFormat('31/12/2020')); // 'DD/MM/YYYY'\n} catch (err) {\n  console.error(err.message);\n}\n\n// Strftime format\ntry {\n  console.log(guessFormat('Fri, January 30th 2020, 10:00 AM', 'strftime'));\n  // '%a, %B %o %Y, %I:%M %p'\n} catch (err) {\n  console.error(err.message);\n}\n\n// Ambiguous input returns array\ntry {\n  console.log(guessFormat('01/01/2020')); // ['DD/MM/YYYY', 'MM/DD/YYYY']\n} catch (err) {\n  console.error(err.message);\n}","lang":"javascript","description":"Shows how to guess date format from a string using moment-guess, including default and strftime outputs, and handling ambiguous input.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}