Comparing version 1.0.0 to 1.1.0
# Changelog | ||
## 1.1.0 | ||
* Support for zone names with more than two components | ||
* Fixed long-term-accurate conversions for months | ||
* Added `weeksInWeekYear` | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ * The big one-oh. No changes from 0.5.8. |
{ | ||
"name": "luxon", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Immutable date wrapper", | ||
@@ -5,0 +5,0 @@ "author": "Isaac Cambron", |
# Luxon | ||
[![MIT License][license-image]][license] [![Build Status][travis-image]][travis-url] [![NPM version][npm-version-image]][npm-url] [![Coverage Status][test-coverage-image]][test-coverage-url] [![Doc coverage][doc-coverage-image]][doc-url] | ||
[![MIT License][license-image]][license] [![Build Status][travis-image]][travis-url] [![NPM version][npm-version-image]][npm-url] [![Coverage Status][test-coverage-image]][test-coverage-url] [![Doc coverage][doc-coverage-image]][doc-url] [![PRs welcome][contributing-image]][contributing-url] | ||
@@ -51,2 +51,5 @@ Luxon is a library for working with dates and times in Javascript. | ||
[contributing-url]: https://moment.github.io/luxon/docs/manual/contributing.html | ||
[contributing-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg | ||
[phasers-image]: https://img.shields.io/badge/phasers-stun-brightgreen.svg |
@@ -85,6 +85,6 @@ import { isUndefined, isNumber, normalizeObject } from './impl/util'; | ||
days: daysInMonthAccurate, | ||
hours: daysInYearAccurate * 24, | ||
minutes: daysInYearAccurate * 24 * 60, | ||
seconds: daysInYearAccurate * 24 * 60 * 60, | ||
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000 | ||
hours: daysInMonthAccurate * 24, | ||
minutes: daysInMonthAccurate * 24 * 60, | ||
seconds: daysInMonthAccurate * 24 * 60 * 60, | ||
milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000 | ||
} | ||
@@ -91,0 +91,0 @@ }, |
@@ -1,2 +0,10 @@ | ||
import { numberBetween, isLeapYear, timeObject, daysInYear, daysInMonth, isNumber } from './util'; | ||
import { | ||
numberBetween, | ||
isLeapYear, | ||
timeObject, | ||
daysInYear, | ||
daysInMonth, | ||
weeksInWeekYear, | ||
isNumber | ||
} from './util'; | ||
@@ -11,14 +19,2 @@ const nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], | ||
function lastWeekNumber(weekYear) { | ||
const p1 = | ||
(weekYear + | ||
Math.floor(weekYear / 4) - | ||
Math.floor(weekYear / 100) + | ||
Math.floor(weekYear / 400)) % | ||
7, | ||
last = weekYear - 1, | ||
p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7; | ||
return p1 === 4 || p2 === 3 ? 53 : 52; | ||
} | ||
function computeOrdinal(year, month, day) { | ||
@@ -49,4 +45,4 @@ return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1]; | ||
weekYear = year - 1; | ||
weekNumber = lastWeekNumber(weekYear); | ||
} else if (weekNumber > lastWeekNumber(year)) { | ||
weekNumber = weeksInWeekYear(weekYear); | ||
} else if (weekNumber > weeksInWeekYear(year)) { | ||
weekYear = year + 1; | ||
@@ -99,3 +95,3 @@ weekNumber = 1; | ||
const validYear = isNumber(obj.weekYear), | ||
validWeek = numberBetween(obj.weekNumber, 1, lastWeekNumber(obj.weekYear)), | ||
validWeek = numberBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)), | ||
validWeekday = numberBetween(obj.weekday, 1, 7); | ||
@@ -102,0 +98,0 @@ |
@@ -224,3 +224,3 @@ import { hasFormatToParts, hasIntl, padStart, roundTo } from './util'; | ||
// todo: cache me | ||
listingMode(defaultOk = true) { | ||
listingMode(defaultOK = true) { | ||
const intl = hasIntl(), | ||
@@ -239,3 +239,3 @@ hasFTP = intl && hasFormatToParts(), | ||
if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOk) { | ||
if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOK) { | ||
return 'error'; | ||
@@ -242,0 +242,0 @@ } else if (!hasFTP || (isActuallyEn && hasNoWeirdness)) { |
@@ -122,2 +122,14 @@ /* | ||
export function weeksInWeekYear(weekYear) { | ||
const p1 = | ||
(weekYear + | ||
Math.floor(weekYear / 4) - | ||
Math.floor(weekYear / 100) + | ||
Math.floor(weekYear / 400)) % | ||
7, | ||
last = weekYear - 1, | ||
p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7; | ||
return p1 === 4 || p2 === 3 ? 53 : 52; | ||
} | ||
export function untruncateYear(year) { | ||
@@ -124,0 +136,0 @@ if (year > 99) { |
@@ -57,3 +57,3 @@ import { parseZoneInfo, isUndefined } from '../impl/util'; | ||
static isValidSpecifier(s) { | ||
return s && s.match(/^[a-z_+-]{1,256}\/[a-z_+-]{1,256}$/i); | ||
return s && s.match(/^[a-z_+-]{1,256}\/[a-z_+-]{1,256}(\/[a-z_+-]{1,256})?$/i); | ||
} | ||
@@ -60,0 +60,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2207837
28279
55