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

@influxdata/giraffe

Package Overview
Dependencies
Maintainers
21
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@influxdata/giraffe - npm Package Compare versions

Comparing version 0.31.0 to 0.31.1

2

package.json
{
"name": "@influxdata/giraffe",
"version": "0.31.0",
"version": "0.31.1",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -107,2 +107,45 @@ import {

test('24 hour format and UTC format without "a" should not show "24" for midnight', () => {
const utcFormatterWithFormat = timeFormatter({
timeZone: 'UTC',
format: 'YYYY-MM-DD HH:mm:ss ZZ',
})
const nonUTCFormatterWithFormat = timeFormatter({
timeZone: 'Europe/Berlin',
format: 'YYYY-MM-DD HH:mm:ss ZZ',
hour12: false,
})
let midnight = new Date('2019-01-01T00:00Z')
expect(utcFormatterWithFormat(midnight)).toEqual('2019-01-01 00:00:00 UTC')
midnight = new Date('2019-01-01T24:00Z')
expect(utcFormatterWithFormat(midnight)).toEqual('2019-01-02 00:00:00 UTC')
midnight = new Date('2019-01-01T23:00Z')
expect(nonUTCFormatterWithFormat(midnight)).toEqual(
'2019-01-02 00:00:00 GMT+1'
)
})
test('24 hour format and UTC format without "a" should display correctly', () => {
const utcFormatterWithFormat = timeFormatter({
timeZone: 'UTC',
format: 'YYYY-MM-DD HH:mm:ss ZZ',
})
const nonUTCFormatterWithFormat = timeFormatter({
timeZone: 'Europe/Berlin',
format: 'YYYY-MM-DD HH:mm:ss ZZ',
hour12: false,
})
let date = new Date('2019-01-01T15:00Z')
expect(utcFormatterWithFormat(date)).toEqual('2019-01-01 15:00:00 UTC')
expect(nonUTCFormatterWithFormat(date)).toEqual('2019-01-01 16:00:00 GMT+1')
date = new Date('2019-01-01T07:00Z')
expect(utcFormatterWithFormat(date)).toEqual('2019-01-01 07:00:00 UTC')
expect(nonUTCFormatterWithFormat(date)).toEqual('2019-01-01 08:00:00 GMT+1')
})
test('can format times with format strings', () => {

@@ -109,0 +152,0 @@ const tests = [

@@ -133,2 +133,5 @@ /*

}: TimeFormatterFactoryOptions = {}): TimeFormatter => {
// RegEx to check for "UTC" case insensitive
const UTC_TIME_ZONE = /utc/i
// this check is used to determine whether a user's locale is 24h or 12h

@@ -145,5 +148,13 @@ const is24hourLocale = new Date(2014, 1, 1, 15, 0, 0, 0)

// and the total number of ticks consistent regardless of time frame
hh: ({hour}) => (Number(hour) < 10 ? ` ${Number(hour)}` : String(hour)),
HH: ({lhour}) => {
hh: options => {
const {hour} = options
const numericalHour = Number(hour)
return numericalHour < 10 ? ` ${numericalHour}` : `${numericalHour}`
},
HH: options => {
const {hour, lhour} = options
const hasMeridiem = / a/i
const is24hourFormat =
is24hourLocale || UTC_TIME_ZONE.test(timeZone) || hour12 === false
if (hasMeridiem.test(format)) {

@@ -158,3 +169,7 @@ if (Number(lhour) === 0) {

}
return lhour
if (is24hourFormat) {
const numericalHour = Number(lhour) % 24
return numericalHour < 10 ? `0${numericalHour}` : `${numericalHour}`
}
return hour
},

@@ -161,0 +176,0 @@ sss: (_, date) => String(date.getMilliseconds()).padStart(3, '0'),

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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