Skip to content

Commit

Permalink
doc: add more common examples (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
YC committed May 8, 2022
1 parent aa6ab8b commit 5d1cfe4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions site/demo/demo.js
Expand Up @@ -19,6 +19,8 @@ function demo(luxon) {
return "[ DateTime " + result.toISO() + " ]";
case result instanceof Duration:
return "[ Duration " + JSON.stringify(result.toObject()) + " ]";
case result instanceof Date:
return "[ Date " + result.toString() + " ]";
default:
return JSON.stringify(result);
}
Expand All @@ -37,18 +39,23 @@ function demo(luxon) {

example("Info.features()");
example("DateTime.now()");
example("DateTime.local(2017, 5, 15, 17, 36)");
example("DateTime.now().toUnixInteger()");
example("DateTime.now().toJSDate()");
example("DateTime.utc().toISO()");
example("DateTime.utc(2017, 5, 15, 17, 36)");
example("DateTime.now().toUTC()");
example("DateTime.utc(2017, 5, 15, 17, 36).toLocal()");
example("DateTime.local(2017, 5, 15, 17, 36)");
example("DateTime.local(2017, 5, 15, 17, 36).toUTC()");
example("DateTime.now().toObject()");
example("DateTime.fromObject({year: 2017, month: 5, day: 15, hour: 17, minute: 36})");
example("DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 })");
example(
"DateTime.fromObject({year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'America/New_York' })"
"DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'America/New_York' })"
);
example(
"DateTime.fromObject({year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'Asia/Singapore' })"
"DateTime.fromObject({ year: 2017, month: 5, day: 15, hour: 17, minute: 36 }, { zone: 'Asia/Singapore' })"
);
example("DateTime.now().setZone('America/New_York')");
example("DateTime.now().setZone('America/New_York').startOf('day')");
example("DateTime.now().plus({minutes: 15, seconds: 8})");
example("DateTime.now().plus({days: 6})");
example("DateTime.now().minus({days: 6})");
Expand Down

0 comments on commit 5d1cfe4

Please sign in to comment.