Compare commits

..

No commits in common. "master" and "v4.0.8" have entirely different histories.

10 changed files with 754 additions and 4030 deletions

View File

@ -1,26 +1,5 @@
# Changelog # 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) ## 2024-06-23 - 4.0.8 - fix(documentation)
Corrected formatting issues in changelog.md Corrected formatting issues in changelog.md

View File

@ -1,7 +1,7 @@
{ {
"name": "@push.rocks/smarttime", "name": "@push.rocks/smarttime",
"private": false, "private": false,
"version": "4.2.0", "version": "4.0.8",
"description": "Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.", "description": "Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
@ -13,22 +13,21 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.2.0", "@git.zone/tsbuild": "^2.1.80",
"@git.zone/tsbundle": "^2.1.0", "@git.zone/tsbundle": "^2.0.15",
"@git.zone/tsrun": "^1.3.3", "@git.zone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.90", "@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.5.3", "@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^22.10.2" "@types/node": "^20.14.8"
}, },
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.1.0", "@push.rocks/lik": "^6.0.15",
"@push.rocks/smartdelay": "^3.0.5", "@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartpromise": "^4.0.4", "@push.rocks/smartpromise": "^4.0.3",
"croner": "^9.0.0", "croner": "^7.0.3",
"date-fns": "^4.1.0", "dayjs": "^1.11.11",
"dayjs": "^1.11.13",
"is-nan": "^1.3.2", "is-nan": "^1.3.2",
"pretty-ms": "^9.2.0" "pretty-ms": "^8.0.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4722
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +0,0 @@
import * as smarttime from '../ts/index.js';
console.log(smarttime.getMilliSecondsAsHumanReadableAgoTime(Date.now()));

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smarttime', name: '@push.rocks/smarttime',
version: '4.2.0', version: '4.0.8',
description: 'Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.' description: 'Provides utilities for advanced time handling including cron jobs, timestamps, intervals, and more.'
} }

View File

@ -8,7 +8,7 @@ export type TJobFunction =
| ((triggerTimeArg?: number) => Promise<any>); | ((triggerTimeArg?: number) => Promise<any>);
export class CronJob { export class CronJob {
public cronParser: plugins.croner.Cron; public cronParser: plugins.croner;
public status: 'started' | 'stopped' | 'initial' = 'initial'; public status: 'started' | 'stopped' | 'initial' = 'initial';
public cronExpression: string; public cronExpression: string;
public jobFunction: TJobFunction; public jobFunction: TJobFunction;
@ -17,7 +17,7 @@ export class CronJob {
constructor(cronManager: CronManager, cronExpressionArg: string, jobFunction: TJobFunction) { constructor(cronManager: CronManager, cronExpressionArg: string, jobFunction: TJobFunction) {
this.cronExpression = cronExpressionArg; this.cronExpression = cronExpressionArg;
this.jobFunction = jobFunction; this.jobFunction = jobFunction;
this.cronParser = new plugins.croner.Cron(cronExpressionArg); this.cronParser = plugins.croner(cronExpressionArg);
} }
/** /**

View File

@ -6,12 +6,11 @@ import * as smartpromise from '@push.rocks/smartpromise';
export { lik, smartdelay, smartpromise }; export { lik, smartdelay, smartpromise };
// third parties; // third parties;
import * as croner from 'croner'; import croner from 'croner';
import * as dateFns from 'date-fns';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import isToday from 'dayjs/plugin/isToday.js'; import isToday from 'dayjs/plugin/isToday.js';
import prettyMs from 'pretty-ms'; import prettyMs from 'pretty-ms';
dayjs.extend(isToday); dayjs.extend(isToday);
export { croner, dateFns, dayjs, prettyMs }; export { croner, dayjs, prettyMs };

View File

@ -67,7 +67,3 @@ export let getMilliSecondsFromUnits = (combinationArg: IUnitCombinationArg) => {
export const getMilliSecondsAsHumanReadableString = (milliSecondsArg: number): string => { export const getMilliSecondsAsHumanReadableString = (milliSecondsArg: number): string => {
return plugins.prettyMs(milliSecondsArg); return plugins.prettyMs(milliSecondsArg);
}; };
export const getMilliSecondsAsHumanReadableAgoTime = (timeStampArg: number): string => {
return plugins.dateFns.formatDistanceToNow(new Date(timeStampArg));
}