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

@hig/timestamp

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hig/timestamp - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

90

build/index.es.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { cx, css } from 'emotion';
import { css, cx } from 'emotion';
import ThemeContext from '@hig/theme-context';
var sequences = Object.freeze({
ABC: "abc",
ACB: "acb",
BAC: "bac",
BCA: "bca",
CAB: "cab",
CBA: "cba"
});
var availableSequences = Object.freeze(Object.values(sequences));
function stylesheet(props, themeData) {

@@ -51,8 +62,37 @@ var customStylesheet = props.stylesheet;

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Timestamp.__proto__ || Object.getPrototypeOf(Timestamp)).call.apply(_ref, [this].concat(args))), _this), _this.humanizeTimestamp = function (timestamp) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Timestamp.__proto__ || Object.getPrototypeOf(Timestamp)).call.apply(_ref, [this].concat(args))), _this), _this.getTimestampSequence = function (distance, ellapsedDescriptor) {
var _this$props = _this.props,
plural = _this$props.plural,
timeDescriptors = _this$props.timeDescriptors,
timestampSequence = _this$props.timestampSequence,
wordSpace = _this$props.wordSpace;
var userTimestamp = void 0;
switch (timestampSequence) {
case "acb":
userTimestamp = wordSpace ? distance + " " + timeDescriptors.ago + " " + ellapsedDescriptor : "" + distance + timeDescriptors.ago + ellapsedDescriptor;
break;
case "bac":
userTimestamp = wordSpace ? ellapsedDescriptor + " " + distance + " " + timeDescriptors.ago : "" + ellapsedDescriptor + distance + timeDescriptors.ago;
break;
case "bca":
userTimestamp = wordSpace ? ellapsedDescriptor + " " + timeDescriptors.ago + " " + distance : "" + ellapsedDescriptor + timeDescriptors.ago + distance;
break;
case "cab":
userTimestamp = wordSpace ? timeDescriptors.ago + " " + distance + " " + ellapsedDescriptor : "" + timeDescriptors.ago + distance + ellapsedDescriptor;
break;
case "cba":
userTimestamp = wordSpace ? timeDescriptors.ago + " " + ellapsedDescriptor + " " + distance : "" + timeDescriptors.ago + ellapsedDescriptor + distance;
break;
default:
userTimestamp = wordSpace ? distance + " " + ellapsedDescriptor + " " + timeDescriptors.ago : "" + distance + ellapsedDescriptor + timeDescriptors.ago;
}
return userTimestamp;
}, _this.humanizeTimestamp = function () {
var _this$props2 = _this.props,
plural = _this$props2.plural,
timeDescriptors = _this$props2.timeDescriptors,
timestamp = _this$props2.timestamp;
var asSeconds = Date.parse(timestamp) / 1000; // TODO: handle future timestamps, or bad input?

@@ -94,3 +134,3 @@ var nowAsSeconds = new Date().valueOf() / 1000;

return wordSpace ? distance + " " + ellapsedDescriptor + " " + timeDescriptors.ago : "" + distance + ellapsedDescriptor + timeDescriptors.ago;
return _this.getTimestampSequence(distance, ellapsedDescriptor);
}, _temp), _possibleConstructorReturn(_this, _ret);

@@ -121,3 +161,3 @@ }

{ className: cx(css(styles.timestamp), className) },
_this2.humanizeTimestamp(_this2.props.timestamp)
_this2.humanizeTimestamp()
);

@@ -139,5 +179,5 @@ }

/**
* ISO date string
* Adds custom/overriding styles
*/
timestamp: PropTypes.string,
stylesheet: PropTypes.func,
/**

@@ -159,6 +199,11 @@ * An object that allows for localization of all the time words used

/**
* Adds custom/overriding styles
* ISO date string
*/
stylesheet: PropTypes.func,
timestamp: PropTypes.string,
/**
* The sequence in which the timestamp is displayed
* ie. 4 seconds ago (abc)
*/
timestampSequence: PropTypes.oneOf(availableSequences),
/**
* If you want a space between words

@@ -180,2 +225,3 @@ */

},
timestampSequence: availableSequences.ABC,
wordSpace: true

@@ -198,8 +244,8 @@ };

},
"timestamp": {
"stylesheet": {
"type": {
"name": "string"
"name": "func"
},
"required": false,
"description": "ISO date string"
"description": "Adds custom/overriding styles"
},

@@ -251,9 +297,22 @@ "timeDescriptors": {

},
"stylesheet": {
"timestamp": {
"type": {
"name": "func"
"name": "string"
},
"required": false,
"description": "Adds custom/overriding styles"
"description": "ISO date string"
},
"timestampSequence": {
"type": {
"name": "enum",
"computed": true,
"value": "availableSequences"
},
"required": false,
"description": "The sequence in which the timestamp is displayed\nie. 4 seconds ago (abc)",
"defaultValue": {
"value": "availableSequences.ABC",
"computed": true
}
},
"wordSpace": {

@@ -274,1 +333,2 @@ "type": {

export default Timestamp;
export { sequences, availableSequences };

@@ -13,2 +13,13 @@ 'use strict';

var sequences = Object.freeze({
ABC: "abc",
ACB: "acb",
BAC: "bac",
BCA: "bca",
CAB: "cab",
CBA: "cba"
});
var availableSequences = Object.freeze(Object.values(sequences));
function stylesheet(props, themeData) {

@@ -59,8 +70,37 @@ var customStylesheet = props.stylesheet;

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Timestamp.__proto__ || Object.getPrototypeOf(Timestamp)).call.apply(_ref, [this].concat(args))), _this), _this.humanizeTimestamp = function (timestamp) {
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Timestamp.__proto__ || Object.getPrototypeOf(Timestamp)).call.apply(_ref, [this].concat(args))), _this), _this.getTimestampSequence = function (distance, ellapsedDescriptor) {
var _this$props = _this.props,
plural = _this$props.plural,
timeDescriptors = _this$props.timeDescriptors,
timestampSequence = _this$props.timestampSequence,
wordSpace = _this$props.wordSpace;
var userTimestamp = void 0;
switch (timestampSequence) {
case "acb":
userTimestamp = wordSpace ? distance + " " + timeDescriptors.ago + " " + ellapsedDescriptor : "" + distance + timeDescriptors.ago + ellapsedDescriptor;
break;
case "bac":
userTimestamp = wordSpace ? ellapsedDescriptor + " " + distance + " " + timeDescriptors.ago : "" + ellapsedDescriptor + distance + timeDescriptors.ago;
break;
case "bca":
userTimestamp = wordSpace ? ellapsedDescriptor + " " + timeDescriptors.ago + " " + distance : "" + ellapsedDescriptor + timeDescriptors.ago + distance;
break;
case "cab":
userTimestamp = wordSpace ? timeDescriptors.ago + " " + distance + " " + ellapsedDescriptor : "" + timeDescriptors.ago + distance + ellapsedDescriptor;
break;
case "cba":
userTimestamp = wordSpace ? timeDescriptors.ago + " " + ellapsedDescriptor + " " + distance : "" + timeDescriptors.ago + ellapsedDescriptor + distance;
break;
default:
userTimestamp = wordSpace ? distance + " " + ellapsedDescriptor + " " + timeDescriptors.ago : "" + distance + ellapsedDescriptor + timeDescriptors.ago;
}
return userTimestamp;
}, _this.humanizeTimestamp = function () {
var _this$props2 = _this.props,
plural = _this$props2.plural,
timeDescriptors = _this$props2.timeDescriptors,
timestamp = _this$props2.timestamp;
var asSeconds = Date.parse(timestamp) / 1000; // TODO: handle future timestamps, or bad input?

@@ -102,3 +142,3 @@ var nowAsSeconds = new Date().valueOf() / 1000;

return wordSpace ? distance + " " + ellapsedDescriptor + " " + timeDescriptors.ago : "" + distance + ellapsedDescriptor + timeDescriptors.ago;
return _this.getTimestampSequence(distance, ellapsedDescriptor);
}, _temp), _possibleConstructorReturn(_this, _ret);

@@ -129,3 +169,3 @@ }

{ className: emotion.cx(emotion.css(styles.timestamp), className) },
_this2.humanizeTimestamp(_this2.props.timestamp)
_this2.humanizeTimestamp()
);

@@ -147,5 +187,5 @@ }

/**
* ISO date string
* Adds custom/overriding styles
*/
timestamp: PropTypes.string,
stylesheet: PropTypes.func,
/**

@@ -167,6 +207,11 @@ * An object that allows for localization of all the time words used

/**
* Adds custom/overriding styles
* ISO date string
*/
stylesheet: PropTypes.func,
timestamp: PropTypes.string,
/**
* The sequence in which the timestamp is displayed
* ie. 4 seconds ago (abc)
*/
timestampSequence: PropTypes.oneOf(availableSequences),
/**
* If you want a space between words

@@ -188,2 +233,3 @@ */

},
timestampSequence: availableSequences.ABC,
wordSpace: true

@@ -206,8 +252,8 @@ };

},
"timestamp": {
"stylesheet": {
"type": {
"name": "string"
"name": "func"
},
"required": false,
"description": "ISO date string"
"description": "Adds custom/overriding styles"
},

@@ -259,9 +305,22 @@ "timeDescriptors": {

},
"stylesheet": {
"timestamp": {
"type": {
"name": "func"
"name": "string"
},
"required": false,
"description": "Adds custom/overriding styles"
"description": "ISO date string"
},
"timestampSequence": {
"type": {
"name": "enum",
"computed": true,
"value": "availableSequences"
},
"required": false,
"description": "The sequence in which the timestamp is displayed\nie. 4 seconds ago (abc)",
"defaultValue": {
"value": "availableSequences.ABC",
"computed": true
}
},
"wordSpace": {

@@ -282,1 +341,3 @@ "type": {

exports.default = Timestamp;
exports.sequences = sequences;
exports.availableSequences = availableSequences;

@@ -0,1 +1,8 @@

# [@hig/timestamp-v1.3.0](https://github.com/Autodesk/hig/compare/@hig/timestamp@1.2.0...@hig/timestamp@1.3.0) (2020-10-15)
### Features
* add timestampSequence prop to help with localization ([f777858](https://github.com/Autodesk/hig/commit/f777858))
# [@hig/timestamp-v1.2.0](https://github.com/Autodesk/hig/compare/@hig/timestamp@1.1.1...@hig/timestamp@1.2.0) (2020-08-18)

@@ -2,0 +9,0 @@

6

package.json
{
"name": "@hig/timestamp",
"version": "1.2.0",
"version": "1.3.0",
"description": "HIG Timestamp",

@@ -33,4 +33,4 @@ "author": "Autodesk Inc.",

"peerDependencies": {
"@hig/theme-context": "^3.0.0",
"@hig/theme-data": "^2.17.0",
"@hig/theme-context": "^3.0.1",
"@hig/theme-data": "^2.18.0",
"react": "^15.4.1 || ^16.3.2"

@@ -37,0 +37,0 @@ },

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