Socket
Socket
Sign inDemoInstall

@splunk/moment

Package Overview
Dependencies
6
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @splunk/moment

Splunk timezone and formatting plugins for moment.js


Version published
Weekly downloads
562
increased by6.04%
Maintainers
2
Install size
2.66 MB
Created
Weekly downloads
 

Readme

Source

@splunk/moment

A package of Moment and Moment Timezone plugins for Splunk Enterprise timezones, and formatting for locales with second and millisecond precision.

Install

Install the package:

npm install @splunk/moment

Usage

Import moment from the Splunk UI package. This provides a Moment class with the timezone and timezone util plugins.

import moment from '@splunk/moment';

Create new moment instances in the server timezone and locale.

const time1 = moment.newSplunkTime({time: 1490500800});
const time2 = moment.newSplunkTime({time: '10/10/2017', format: 'l'});

Manipulate and query times using the Moment API.

time1.subtract(1, 'day').startOf('day';);
const isBefore = time1.isBefore(time2);

Format Times using second or millisecond precision

const displayValue = time1.splunkFormat('lls');

Advanced Usage

If used in an environment without the window.$C properties set by splunkweb, there are functions to setup and use the plugins with raw timezone data from Splunk Enterprise.

The timezone data can be retrieved from services/search/timeparser/tz. To access this service from the client, the endpoint must be exposed in web.conf.

For example:

http://localhost:8000/en-US/splunkd/__raw/services/search/timeparser/tz

Set this data as the default Splunk Enterprise timezone, which can be used for creating and manipulating times.

const splunkTimezoneName = moment.setDefaultSplunkTimezone(zoneData);

const time = moment.newSplunkTime({time: 1490500800}); // uses the default timezone
const nowInTokyo = moment.tz('Asia/Tokyo').locale('ja_JP');
const nowAtServer = nowInTokyo.clone().tz(splunkTimezoneName).locale('en_US');

FAQs

Last updated on 07 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc