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

ldap2date

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap2date - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

23

ldap2date.js

@@ -54,4 +54,25 @@ ;(function() {

},
getTimeZone : function getTimeZone(time) {
var length = time.length
if (time.charAt(length - 1 ) === 'Z') return 0
if (time.indexOf('+') !== -1) {
var symbolIdx = time.indexOf('+')
} else if (time.indexOf('-') !== -1) {
var symbolIdx = time.indexOf('-')
} else {
throw new Error('Invalid timezone')
}
var minutes = time.substring(symbolIdx + 2)
var hours = time.substring(symbolIdx + 1, symbolIdx + 2)
var one = (time.charAt(symbolIdx) === '+') ? 1 : -1
var intHr = one * parseInt(hours) * 60 * 60 * 1000
var intMin = one * parseInt(minutes) * 60 * 1000
var ms = minutes ? intHr + intMin : intHr
return ms
},
parse : function parse(time) {
var date = new Date()
var ms = this.getMilliseconds(time) + this.getTimeZone(time)
date.setUTCFullYear(this.getYear(time))

@@ -63,3 +84,3 @@ date.setUTCMonth(this.getMonth(time))

date.setUTCSeconds(this.getSeconds(time))
date.setUTCMilliseconds(this.getMilliseconds(time))
date.setUTCMilliseconds(ms)

@@ -66,0 +87,0 @@ var msg = date.toString()

2

package.json
{
"name": "ldap2date",
"version": "0.1.2",
"version": "0.2.0",
"description": "Parses LDAP Generalized Time Syntax",

@@ -5,0 +5,0 @@ "main": "ldap2date.js",

@@ -9,3 +9,3 @@ [![Build Status](https://travis-ci.org/rsolomo/ldap2date.js.png?branch=master)](https://travis-ci.org/rsolomo/ldap2date.js)

If so, the methods below may help you. Currently, only 'Z', style strings are supported.
If so, the methods below may help you.

@@ -12,0 +12,0 @@ ## Usage

@@ -93,2 +93,33 @@ var assert = require('assert')

describe('getTimeZone', function() {
it('should return ms representation of + timezone', function() {
var ms = ldap2date.getTimeZone('20130228192706.8+531')
assert.equal(ms, 19860000)
})
it('should return ms representation of - timezone', function() {
var ms = ldap2date.getTimeZone('20130228192706.8-531')
assert.equal(ms, -19860000)
})
it('should return 0 for \'Z\' timezone', function() {
var ms = ldap2date.getTimeZone('20130228192706.8Z')
assert.equal(ms, 0)
})
it('minutes should be optional', function() {
var ms = ldap2date.getTimeZone('20130228192706.8+5')
assert.equal(ms, 18000000)
})
it('should throw an Error if the timezone is not present', function() {
assert.throws(
function() {
ldap2date.getTimeZone('20130228192706.85')
},
/timezone/i
)
})
})
describe('parse', function() {

@@ -106,2 +137,7 @@ it('should return a Date object representing the time', function() {

it('should parse timezones', function() {
var date = ldap2date.parse('20130228192706.607Z+500')
assert.equal(date.valueOf(), 1362097626607)
})
it('should throw an Error if the parsed date is invalid', function() {

@@ -108,0 +144,0 @@ assert.throws(

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