6.1.9 • Published 13 days ago

@meniga/dates v6.1.9

Weekly downloads
112
License
MIT
Repository
-
Last release
13 days ago

@meniga/dates

Dates is a utility library for working with dates and date locales. It's basically a wrapper for moment js right now but is abstracted so that we can easily switch 3rd party libraries if we want).

Exports


Date utilities

dates(date = null, format = null, strict = null)

Wrapper for moment(date, format, strict) or moment() if date is null

maxDate

Wrapper for moment.max

minDate

Wrapper for moment.min

formatDate(date, format, parseFromat, stripTime)

Wrapper for moment(date, parseFormat).format(format). If stripTime is given, the timestamp from the date object will be removed before formatting.

isSameDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSame(compareDate, dateGrouping)

isBeforeDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isBefore(compareDate, dateGrouping)

isAfterDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isAfter(compareDate, dateGrouping)

isSameOrBeforeDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSameOrBefore(compareDate, dateGrouping)

isSameOrAfterDate(date, compareDate, dateGrouping)

Wrapper for moment(date).isSameOrAfter(compareDate, dateGrouping)

isValidDate(date)

Wrapper for moment(date).isValid()

stripTimeFromDate(date)

Removes timestamp information from the date object

getWeekDayInCorrectFormat(format, date)

Formats a weekday in the grammatically correct custom format as defined in the locale settings for moment

getDaysLeft(date)

Returns the day difference between today and the given day

getDatesFromPeriod(period, includeCurrentMonth)

Meniga has a concept of period which is defined as:

0 = This month, 1-12 = Last X months, 'thisYear' = This year, 'lastYear' = Last year

This function gives you an object that includes the period itself, and the start and end dates for the given period. If includeCurrentMonth is true the end date will be the current month, otherwise it will be the last completed month.

Locale utilities

setLocale(locale, config)

Wrapper for moment.locale(locale) and moment.updateLocale(locale, config)

weekdaysShort(day)

Wrapper for moment.weekdaysShort(day)

weekdays(day)

Wrapper for moment.weekdays(day)

months(month)

Wrapper for moment.months(month)

monthsShort(month)

Wrapper for moment.monthsShort(month)

getLocaleObject

Returns a locale object intended for d3 use that includes the following:

{
	'periods': ['AM', 'PM'],
	'days': moment.weekdays(),
	'shortDays': moment.weekdaysShort(),
	'months': moment.months(),
	'shortMonths': moment.monthsShort(),
}

Example usage:

import { getLocaleObject } from '@meniga/dates'
import { timeFormatDefaultLocale } from 'd3-time-format'

const locale = getLocaleObject()
timeFormatDefaultLocale(locale)
6.1.9

13 days ago

6.1.8

1 month ago

6.1.3-alpha.0

1 month ago

6.1.1-alpha.0

1 month ago

6.1.4-alpha.0

1 month ago

6.1.6

1 month ago

6.1.5

1 month ago

6.1.2-alpha.0

1 month ago

6.1.7

1 month ago

6.1.0

1 month ago

6.0.37-alpha.0

1 month ago

6.0.38-alpha.0

1 month ago

6.0.34-alpha.0

1 month ago

6.0.36-alpha.0

1 month ago

6.0.35-alpha.0

1 month ago

6.0.32-alpha.0

1 month ago

6.0.30-alpha.0

1 month ago

6.0.33-alpha.0

1 month ago

6.0.29-alpha.0

1 month ago

6.0.31-alpha.0

1 month ago

6.0.28-alpha.0

2 months ago

6.0.25-alpha.0

2 months ago

6.0.27-alpha.0

2 months ago

6.0.24-alpha.0

2 months ago

6.0.26-alpha.0

2 months ago

6.0.23-alpha.0

2 months ago

6.0.21-alpha.0

4 months ago

6.0.22-alpha.0

4 months ago

6.0.20-alpha.0

4 months ago

6.0.17-alpha.0

4 months ago

6.0.19-alpha.0

4 months ago

6.0.13-alpha.0

4 months ago

6.0.15-alpha.0

4 months ago

6.0.16-alpha.0

4 months ago

6.0.18-alpha.0

4 months ago

6.0.12

4 months ago

6.0.2-alpha.0

6 months ago

5.0.0-alpha.14902

6 months ago

1.0.0-alpha.0

6 months ago

6.0.7-alpha.0

6 months ago

6.0.9-alpha.0

6 months ago

6.0.1-alpha.0

6 months ago

6.0.0

6 months ago

6.0.4

6 months ago

4.11.1-alpha.120

3 years ago

5.0.0-alpha.48

3 years ago

5.0.0-alpha.47

3 years ago

5.0.0-alpha.17

3 years ago

5.0.0-alpha.18

3 years ago

5.0.0-alpha.0

3 years ago

4.9.1-alpha.185

3 years ago

4.9.1-alpha.176

3 years ago

4.9.1-alpha.169

3 years ago

4.9.1-alpha.134

3 years ago

4.9.0

4 years ago

4.8.1-alpha.233

4 years ago

4.8.1-alpha.181

4 years ago

4.8.1-alpha.182

4 years ago

4.8.1-alpha.148

4 years ago

4.8.1-alpha.46

4 years ago

4.8.1-alpha.45

4 years ago

4.8.1-alpha.44

4 years ago

4.8.0

4 years ago

4.6.1-alpha.250

4 years ago

4.6.1-alpha.217

4 years ago

4.6.1-alpha.204

4 years ago

4.6.1-alpha.174

4 years ago

4.6.1-alpha.175

4 years ago

4.6.1-alpha.160

4 years ago

4.6.1-alpha.16

5 years ago

4.6.0

5 years ago

4.2.1-alpha.1

5 years ago

4.2.0

5 years ago

4.1.1-alpha.175

5 years ago

4.1.1-alpha.174

5 years ago

4.1.1-alpha.115

5 years ago

4.1.1-alpha.114

5 years ago

4.1.1-alpha.113

5 years ago

4.1.1-alpha.110

5 years ago

4.1.1-alpha.74

5 years ago

4.1.0

5 years ago

4.0.4-alpha.229

5 years ago

4.0.4-alpha.192

5 years ago

4.0.4-alpha.191

5 years ago