Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
51943fad1c | |||
ce3af11ca8 | |||
a941f10af3 | |||
6e7f8f3dda | |||
bfa00feadd | |||
55c2d95b7d | |||
71ce4de8ff | |||
491176bb35 |
21
changelog.md
21
changelog.md
@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-12-14 - 4.2.0 - feat(ondemand)
|
||||
Add on-demand timestamp feature
|
||||
|
||||
- Added an on-demand script to output human-readable time ago for current timestamp.
|
||||
|
||||
## 2024-12-13 - 4.1.1 - fix(smarttime.units)
|
||||
Fix issue in getMilliSecondsAsHumanReadableAgoTime
|
||||
|
||||
- Corrected the parameter type passed to date-fns.formatDistanceToNow within getMilliSecondsAsHumanReadableAgoTime function.
|
||||
|
||||
## 2024-12-13 - 4.1.0 - feat(smarttime.units)
|
||||
Add function to get human-readable time ago string from milliseconds.
|
||||
|
||||
- Introduced `getMilliSecondsAsHumanReadableAgoTime` to convert a timestamp to a human-readable text indicating time ago.
|
||||
|
||||
## 2024-12-13 - 4.0.9 - fix(dependencies)
|
||||
Updated dependencies in package.json and resolved cron function issues.
|
||||
|
||||
- Updated multiple dependencies in package.json to their latest versions.
|
||||
- Fixed issue in cron job instantiation by correcting the import and initialization of the croner.Cron class.
|
||||
|
||||
## 2024-06-23 - 4.0.8 - fix(documentation)
|
||||
Corrected formatting issues in changelog.md
|
||||
|
||||
|
23
package.json
23
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@push.rocks/smarttime",
|
||||
"private": false,
|
||||
"version": "4.0.8",
|
||||
"version": "4.2.0",
|
||||
"description": "Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -13,21 +13,22 @@
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.80",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.0.23",
|
||||
"@types/node": "^20.14.8"
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.10.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@push.rocks/lik": "^6.0.15",
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"croner": "^7.0.3",
|
||||
"dayjs": "^1.11.11",
|
||||
"@push.rocks/smartpromise": "^4.0.4",
|
||||
"croner": "^9.0.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"is-nan": "^1.3.2",
|
||||
"pretty-ms": "^8.0.0"
|
||||
"pretty-ms": "^9.2.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
4734
pnpm-lock.yaml
generated
4734
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
3
test/ondemand.ts
Normal file
3
test/ondemand.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import * as smarttime from '../ts/index.js';
|
||||
|
||||
console.log(smarttime.getMilliSecondsAsHumanReadableAgoTime(Date.now()));
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smarttime',
|
||||
version: '4.0.8',
|
||||
version: '4.2.0',
|
||||
description: 'Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.'
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ export type TJobFunction =
|
||||
| ((triggerTimeArg?: number) => Promise<any>);
|
||||
|
||||
export class CronJob {
|
||||
public cronParser: plugins.croner;
|
||||
public cronParser: plugins.croner.Cron;
|
||||
public status: 'started' | 'stopped' | 'initial' = 'initial';
|
||||
public cronExpression: string;
|
||||
public jobFunction: TJobFunction;
|
||||
@ -17,7 +17,7 @@ export class CronJob {
|
||||
constructor(cronManager: CronManager, cronExpressionArg: string, jobFunction: TJobFunction) {
|
||||
this.cronExpression = cronExpressionArg;
|
||||
this.jobFunction = jobFunction;
|
||||
this.cronParser = plugins.croner(cronExpressionArg);
|
||||
this.cronParser = new plugins.croner.Cron(cronExpressionArg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,11 +6,12 @@ import * as smartpromise from '@push.rocks/smartpromise';
|
||||
export { lik, smartdelay, smartpromise };
|
||||
|
||||
// third parties;
|
||||
import croner from 'croner';
|
||||
import * as croner from 'croner';
|
||||
import * as dateFns from 'date-fns';
|
||||
import dayjs from 'dayjs';
|
||||
import isToday from 'dayjs/plugin/isToday.js';
|
||||
import prettyMs from 'pretty-ms';
|
||||
|
||||
dayjs.extend(isToday);
|
||||
|
||||
export { croner, dayjs, prettyMs };
|
||||
export { croner, dateFns, dayjs, prettyMs };
|
||||
|
@ -67,3 +67,7 @@ export let getMilliSecondsFromUnits = (combinationArg: IUnitCombinationArg) => {
|
||||
export const getMilliSecondsAsHumanReadableString = (milliSecondsArg: number): string => {
|
||||
return plugins.prettyMs(milliSecondsArg);
|
||||
};
|
||||
|
||||
export const getMilliSecondsAsHumanReadableAgoTime = (timeStampArg: number): string => {
|
||||
return plugins.dateFns.formatDistanceToNow(new Date(timeStampArg));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user