.isOlderThan() and .isYoungerThan now support compareTimeArg
This commit is contained in:
parent
633ec0606b
commit
824e055cbd
4
dist/smarttime.classes.timestamp.d.ts
vendored
4
dist/smarttime.classes.timestamp.d.ts
vendored
@ -34,6 +34,6 @@ export declare class TimeStamp {
|
||||
* Is the current instance older than the argument
|
||||
* @param TimeStampArg
|
||||
*/
|
||||
isOlderThan(TimeStampArg: TimeStamp): boolean;
|
||||
isYoungerThan(TimeStampArg: TimeStamp): boolean;
|
||||
isOlderThan(TimeStampArg: TimeStamp, compareTimeArg?: number): boolean;
|
||||
isYoungerThan(TimeStampArg: TimeStamp, compareTimeArg?: number): boolean;
|
||||
}
|
||||
|
14
dist/smarttime.classes.timestamp.js
vendored
14
dist/smarttime.classes.timestamp.js
vendored
@ -38,16 +38,20 @@ class TimeStamp {
|
||||
* Is the current instance older than the argument
|
||||
* @param TimeStampArg
|
||||
*/
|
||||
isOlderThan(TimeStampArg) {
|
||||
if (this.milliSeconds < TimeStampArg.milliSeconds) {
|
||||
isOlderThan(TimeStampArg, compareTimeArg) {
|
||||
if (this.milliSeconds < TimeStampArg.milliSeconds &&
|
||||
(!compareTimeArg ||
|
||||
(compareTimeArg && ((TimeStampArg.milliSeconds - this.milliSeconds) > compareTimeArg)))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
isYoungerThan(TimeStampArg) {
|
||||
if (this.milliSeconds > TimeStampArg.milliSeconds) {
|
||||
isYoungerThan(TimeStampArg, compareTimeArg) {
|
||||
if (this.milliSeconds > TimeStampArg.milliSeconds &&
|
||||
(!compareTimeArg ||
|
||||
(compareTimeArg && ((this.milliSeconds - TimeStampArg.milliSeconds) > compareTimeArg)))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@ -56,4 +60,4 @@ class TimeStamp {
|
||||
}
|
||||
}
|
||||
exports.TimeStamp = TimeStamp;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxl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jQUFjLElBQUksQ0FBQyxDQUFDLFlBQVksQ0FBQyxZQUFZLEdBQUcsSUFBSSxDQUFDLFlBQVksQ0FBQyxHQUFHLGNBQWMsQ0FBQyxDQUNyRixDQUVMLENBQUMsQ0FBQyxDQUFDO1lBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQTtRQUNiLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE1BQU0sQ0FBQyxLQUFLLENBQUE7UUFDZCxDQUFDO0lBQ0gsQ0FBQztJQUVELGFBQWEsQ0FBRSxZQUF1QixFQUFFLGNBQXVCO1FBQzdELEVBQUUsQ0FBQyxDQUNELElBQUksQ0FBQyxZQUFZLEdBQUcsWUFBWSxDQUFDLFlBQVk7WUFDN0MsQ0FDRSxDQUFDLGNBQWM7Z0JBQ2YsQ0FDRSxjQUFjLElBQUksQ0FBQyxDQUFDLElBQUksQ0FBQyxZQUFZLEdBQUcsWUFBWSxDQUFDLFlBQVksQ0FBQyxHQUFHLGNBQWMsQ0FBQyxDQUNyRixDQUVMLENBQUMsQ0FBQyxDQUFDO1lBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQTtRQUNiLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE1BQU0sQ0FBQyxLQUFLLENBQUE7UUFDZCxDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBcEZELDhCQW9GQyJ9
|
@ -57,16 +57,32 @@ export class TimeStamp {
|
||||
* Is the current instance older than the argument
|
||||
* @param TimeStampArg
|
||||
*/
|
||||
isOlderThan (TimeStampArg: TimeStamp) {
|
||||
if (this.milliSeconds < TimeStampArg.milliSeconds) {
|
||||
isOlderThan (TimeStampArg: TimeStamp, compareTimeArg?: number) {
|
||||
if (
|
||||
this.milliSeconds < TimeStampArg.milliSeconds &&
|
||||
(
|
||||
!compareTimeArg ||
|
||||
(
|
||||
compareTimeArg && ((TimeStampArg.milliSeconds - this.milliSeconds) > compareTimeArg)
|
||||
)
|
||||
)
|
||||
) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
isYoungerThan (TimeStampArg: TimeStamp) {
|
||||
if (this.milliSeconds > TimeStampArg.milliSeconds) {
|
||||
isYoungerThan (TimeStampArg: TimeStamp, compareTimeArg?: number) {
|
||||
if (
|
||||
this.milliSeconds > TimeStampArg.milliSeconds &&
|
||||
(
|
||||
!compareTimeArg ||
|
||||
(
|
||||
compareTimeArg && ((this.milliSeconds - TimeStampArg.milliSeconds) > compareTimeArg)
|
||||
)
|
||||
)
|
||||
) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user