Greeting Plugin
Greeting Plugin — Chronos Plugin Documentation.
About Greeting Plugin
Greeting plugin is a plugin that adds greeting related functionalities to Chronos.
Import & Usage
Import
To use the Greeting Plugin, import it first:
import { Chronos, chronos } from "chronos-date";
import { greetingPlugin } from 'chronos-date/plugins/greetingPlugin';Register
Now you can use the plugin's methods:
// Register the plugin globally
Chronos.use(greetingPlugin);
// or
chronos.use(greetingPlugin);
// or
Chronos.register(greetingPlugin);
// or
chronos.register(greetingPlugin);Usage
Example usage of the greetingPlugin:
const c = new Chronos();
const greeting = c.getGreeting();
console.log(greeting);Example Usage
Overview
The greetingPlugin adds comprehensive greeting related functionalities to Chronos, enabling:
- Get a greeting message based on current or provided time periods
Methods Added by the Plugin
Note
All these methods are provided by greetingPlugin. You must register it using Chronos.use(greetingPlugin) before calling them. Once registered, all Chronos instances will have access to these methods.
| Method | Description | Returns |
|---|---|---|
getGreeting | Returns a time-appropriate greeting message based on configurable time periods. | string |
API Reference
getGreeting()
Returns a time-appropriate greeting message based on configurable time periods. Supports custom messages and time thresholds.
Signature
getGreeting(configs?: GreetingConfigs): string;Parameters
configs: Configurations options, e.g. times, msgs.
Return Type
string - The appropriate greeting message.
Alias
greetis an alias forgetGreetingmethod.
Example
import { greetingPlugin } from 'chronos-date/plugins/greetingPlugin';
Chronos.use(greetingPlugin);
// Use with default configs
new Chronos().getGreeting(); // Greeting msg e.g. "Good Afternoon!"
// Custom msg and times
new Chronos().getGreeting({
morningEnds: '10:00',
noonEnds: '14:00',
afternoonEnds: '18:00',
eveningEnds: '22:00',
midnightMessage: 'Working late?',
currentTime: '01:30'
});This method internally uses getGreeting function. For detailed usage please refer to the docs.
Last updated: Wed, Jun 24, 2026 09:04:13AM (UTC)
