Skip to content

Utility method for abbreviating an array of numeric days of the week

License

Notifications You must be signed in to change notification settings

fabrizioq/abbrev-weekday-range

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abbrev-weekday-range

Utility method for abbreviating an array of numeric days of the week.

npm Version Build Status Test Coverage Dependency Status

Installation

Install using npm:

$ npm install abbrev-weekday-range

Usage

Note: This function assumes the array of weekdays given contain the values 0 through 6 (0 = Sunday), are in ascending order, and contain no duplicates.

var abbrevDays = require('abbrev-weekday-range');

abbrevDays([1, 2, 3, 4, 5]); // 'Mon-Fri'
abbrevDays([0, 6]);         // 'Sun, Sat'
abbrevDays([1, 2, 3, 5]);   // 'Mon-Wed, Fri'

abbrevDays([1, 2, 3, 4, 5], { format: 'narrow' }); // 'M-F'
abbrevDays([1, 2, 3, 4, 5], { format: 'long' });   // 'Monday-Friday'

Options

format (default: short)

Format to use when generating range. Supported formats:

  • "narrow" ("S", "M", "T", "W", "T", "F", "S")
  • "shorter" ("Su", "M", "Tu", "W", "Th", "F", "Sa")
  • "short" ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
  • "long" ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

For further customization, format can also be specified as an array of abbreviations, or as a function that recieves a numeric weekday and returns a string.

License

MIT

About

Utility method for abbreviating an array of numeric days of the week

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%