Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow default initialization of DateTime/Duration/Interval #1643

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export default class DateTime {
/**
* @access private
*/
constructor(config) {
constructor(config = {}) {
const zone = config.zone || Settings.defaultZone;

let invalid =
Expand Down
2 changes: 1 addition & 1 deletion src/duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default class Duration {
/**
* @private
*/
constructor(config) {
constructor(config = {}) {
const accurate = config.conversionAccuracy === "longterm" || false;
let matrix = accurate ? accurateMatrix : casualMatrix;

Expand Down
2 changes: 1 addition & 1 deletion src/interval.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class Interval {
/**
* @private
*/
constructor(config) {
constructor(config = {}) {
/**
* @access private
*/
Expand Down
7 changes: 7 additions & 0 deletions test/datetime/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ const withDefaultLocale = Helpers.withDefaultLocale,
withthrowOnInvalid = Helpers.setUnset("throwOnInvalid"),
withDefaultZone = Helpers.withDefaultZone;

//------
// new
//------
test("Default constructor works", () => {
expect(() => new DateTime()).not.toThrow();
});

//------
// .now()
//------
Expand Down
7 changes: 7 additions & 0 deletions test/duration/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import { Duration } from "../../src/luxon";

//------
// new
//------
test("Default constructor works", () => {
expect(() => new Duration()).not.toThrow();
});

//------
// .fromObject()
//-------
Expand Down
7 changes: 7 additions & 0 deletions test/interval/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import Helpers from "../helpers";

const withThrowOnInvalid = Helpers.setUnset("throwOnInvalid");

//------
// new
//------
test("Default constructor works", () => {
expect(() => new Interval()).not.toThrow();
});

//------
// .fromObject()
//-------
Expand Down