Skip to content

Commit

Permalink
Added RealDate.now() and RealTime.now()
Browse files Browse the repository at this point in the history
  • Loading branch information
zaccomode committed Oct 25, 2023
1 parent 2e23e79 commit 70f0bcf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chiral",
"version": "1.0.0",
"version": "1.1.0",
"description": "A library to simplify timekeeping.",
"author": "Isaac Shea <[email protected]>",
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions src/models/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,9 @@ export default class RealDate implements Chiral.Date.I_Date<RealDate> {
"January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December",
];

static now(): RealDate {
const d = new Date();
return new RealDate(d.getFullYear(), d.getMonth() + 1, d.getDate());
}
}
12 changes: 11 additions & 1 deletion src/models/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,20 @@ export default class RealTime implements Chiral.Time.I_Time<RealTime> {
}


// STATIC VALUES
// STATIC
static readonly SUFFIXES = {
AM: " AM",
PM: " PM",
mil: "",
};

static now() {
const now = new Date();
return new RealTime(
now.getHours(),
now.getMinutes(),
now.getSeconds(),
now.getMilliseconds(),
);
}
}

0 comments on commit 70f0bcf

Please sign in to comment.