New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@naturalcycles/time-lib

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@naturalcycles/time-lib - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

7

CHANGELOG.md

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

# [1.6.0](https://github.com/NaturalCycles/time-lib/compare/v1.5.0...v1.6.0) (2019-11-04)
### Features
* ms() to support minutes and hours ([e86bf6c](https://github.com/NaturalCycles/time-lib/commit/e86bf6caffd95af1caae7db15bbb106e7370a309))
# [1.5.0](https://github.com/NaturalCycles/time-lib/compare/v1.4.3...v1.5.0) (2019-08-21)

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

2

dist/plugin/localeData.js

@@ -6,4 +6,4 @@ "use strict";

dayjs.extendLocale = function (ext) {
dayjs.locale(Object.assign({}, dayjs().$locale(), ext));
dayjs.locale(Object.assign(Object.assign({}, dayjs().$locale()), ext));
};
//# sourceMappingURL=localeData.js.map

@@ -11,3 +11,6 @@ export declare const TS_2018_06_21 = 1529539200;

* 11 sec
* 1m12s
* 59m2s
* 1h3m12s
*/
export declare function ms(millis: number): string;

@@ -16,13 +16,26 @@ "use strict";

* 11 sec
* 1m12s
* 59m2s
* 1h3m12s
*/
function ms(millis) {
if (millis >= 10000) {
// <1 sec
if (millis < 1000)
return `${Math.round(millis)} ms`;
// < 5 sec
if (millis < 5000)
return `${(millis / 1000).toFixed(3)} sec`;
// <1 min
if (millis < 60 * 1000)
return `${Math.round(millis / 1000)} sec`;
}
if (millis >= 1000) {
return `${(millis / 1000).toFixed(3)} sec`;
}
return `${Math.round(millis)} ms`;
const sec = Math.round(millis / 1000) % 60;
const min = Math.round(millis / (60 * 1000)) % 60;
const hrs = Math.round(millis / (3600 * 1000));
// <1 hr
if (millis < 3599500)
return `${min}m${sec}s`;
// >= 1hr
return `${hrs}h${min}m${sec}s`;
}
exports.ms = ms;
//# sourceMappingURL=time.util.js.map

@@ -8,3 +8,3 @@ {

"devDependencies": {
"@naturalcycles/dev-lib": "^7.6.0",
"@naturalcycles/dev-lib": "^9.0.2",
"@naturalcycles/js-lib": "^8.2.1",

@@ -37,3 +37,3 @@ "@naturalcycles/test-lib": "^1.0.0",

},
"version": "1.5.0",
"version": "1.6.0",
"description": "Date/time related API, based on DayJS",

@@ -40,0 +40,0 @@ "keywords": [

@@ -8,3 +8,3 @@ import { Dayjs, PluginFunc } from 'dayjs'

*/
toISODate (): string
toISODate(): string

@@ -14,3 +14,3 @@ /**

*/
toPretty (): string
toPretty(): string

@@ -20,3 +20,3 @@ /**

*/
toCompactTime (seconds?: boolean): string
toCompactTime(seconds?: boolean): string

@@ -26,3 +26,3 @@ /**

*/
unixMillis (): number
unixMillis(): number

@@ -32,3 +32,3 @@ /**

*/
today (): Dayjs
today(): Dayjs

@@ -53,21 +53,21 @@ /**

export const defaultPlugins: PluginFunc = (_opt, dayjsClass, _dayjsFactory) => {
dayjsClass.prototype.toISODate = function (this: Dayjs): string {
dayjsClass.prototype.toISODate = function(this: Dayjs): string {
return this.format(DAYJS_ISO_DATE)
}
dayjsClass.prototype.toPretty = function (this: Dayjs): string {
dayjsClass.prototype.toPretty = function(this: Dayjs): string {
return this.format(DAYJS_PRETTY_TIME)
}
dayjsClass.prototype.toCompactTime = function (this: Dayjs, seconds = false): string {
dayjsClass.prototype.toCompactTime = function(this: Dayjs, seconds = false): string {
return this.format(seconds ? DAYJS_COMPACT_TIME_SECONDS : DAYJS_COMPACT_TIME)
}
dayjsClass.prototype.unixMillis = function (this: Dayjs): number {
dayjsClass.prototype.unixMillis = function(this: Dayjs): number {
return this.valueOf()
}
dayjsClass.prototype.today = function (this: Dayjs): Dayjs {
dayjsClass.prototype.today = function(this: Dayjs): Dayjs {
return this.startOf('day')
}
}

@@ -11,3 +11,3 @@ import { Dayjs, PluginFunc } from 'dayjs'

*/
isoWeekday (): number
isoWeekday(): number

@@ -17,3 +17,3 @@ /**

*/
isoWeekday (setWeekday: number): this
isoWeekday(setWeekday: number): this
}

@@ -23,3 +23,3 @@ }

export const isoWeekdayPlugin: PluginFunc = (_opt, dayjsClass) => {
dayjsClass.prototype.isoWeekday = function (this: Dayjs, setWeekday?: number) {
dayjsClass.prototype.isoWeekday = function(this: Dayjs, setWeekday?: number) {
const { $W } = this as any

@@ -26,0 +26,0 @@ const weekday = $W <= 0 ? $W + 7 : $W

@@ -18,9 +18,9 @@ import * as dayjs from 'dayjs'

*/
$locale (): DayjsLocale
$locale(): DayjsLocale
}
export function extendLocale (ext: Partial<DayjsLocale>): void
export function extendLocale(ext: Partial<DayjsLocale>): void
}
;(dayjs as any).extendLocale = function (ext: any) {
;(dayjs as any).extendLocale = function(ext: any) {
dayjs.locale({

@@ -27,0 +27,0 @@ ...dayjs().$locale(),

@@ -8,3 +8,3 @@ import { Dayjs, PluginFunc } from 'dayjs'

*/
week (): number
week(): number

@@ -19,3 +19,3 @@ /**

export const weekOfYearPlugin: PluginFunc = (_opt, dayjsClass, dayjs) => {
dayjsClass.prototype.week = function (this: Dayjs) {
dayjsClass.prototype.week = function(this: Dayjs) {
const weekStart = this.$locale().weekStart || 0

@@ -22,0 +22,0 @@

@@ -6,3 +6,3 @@ export const TS_2018_06_21 = 1529539200

*/
export function since (from: number, until = Date.now()): string {
export function since(from: number, until = Date.now()): string {
return ms(until - from)

@@ -16,13 +16,25 @@ }

* 11 sec
* 1m12s
* 59m2s
* 1h3m12s
*/
export function ms (millis: number): string {
if (millis >= 10000) {
return `${Math.round(millis / 1000)} sec`
}
export function ms(millis: number): string {
// <1 sec
if (millis < 1000) return `${Math.round(millis)} ms`
if (millis >= 1000) {
return `${(millis / 1000).toFixed(3)} sec`
}
// < 5 sec
if (millis < 5000) return `${(millis / 1000).toFixed(3)} sec`
return `${Math.round(millis)} ms`
// <1 min
if (millis < 60 * 1000) return `${Math.round(millis / 1000)} sec`
const sec = Math.round(millis / 1000) % 60
const min = Math.round(millis / (60 * 1000)) % 60
const hrs = Math.round(millis / (3600 * 1000))
// <1 hr
if (millis < 3599500) return `${min}m${sec}s`
// >= 1hr
return `${hrs}h${min}m${sec}s`
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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