systemd-timedated-client

1.0.1 • Public • Published

systemd-timedated-client

systemd-timedated-client provides a client to access the systemd-timedated API.

Install

Add the systemd-timedated-client module as dependency to your package.json and/or run npm install

Library Usage

The API documentation can be found here.

const service = new TimeDateService();
 
async function printData() {
    
    const [date, tz, canNtp, NTPenabled, NTPinSync] = 
        await Promise.all([
        service.getTime(),
        service.getTimezone(),
        service.getCanNTP(),
        service.getNTP(),
        service.getNTPSynchronized()
    ]);
    
    console.log('Date/time:', date.toLocaleString());
    console.log('Timezone:', tz);
    console.log('NTP available:', canNtp);
    console.log('NTP enabled:', NTPenabled);
    console.log('NTP in sync:', NTPinSync);
    console.log('');
}
 
 
async function test() { 
    
    service.on('timezoneChange', tz => console.log('new TZ:', tz));
    service.on('NTPChange', ntp => console.log('NTP state:', ntp));
    
    await service.connect();
    
    printData();
    
    await service.setTimezone('Europe/Amsterdam');
}
 
test();

Dependents (0)

Package Sidebar

Install

npm i systemd-timedated-client

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

47.8 kB

Total Files

7

Last publish

Collaborators

  • robinbolscher
  • weejewel
  • athombv-github-actions