Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@splunk/moment

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splunk/moment

Splunk timezone and formatting plugins for moment.js

  • 0.7.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-0.43%
Maintainers
2
Weekly downloads
 
Created
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

Package last updated on 07 Feb 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc