Compare commits

..

2 Commits

Author SHA1 Message Date
standardci
6a24ba5d56 chore(release): publish new version
- @standardnotes/api-gateway@1.16.1
 - @standardnotes/auth-server@1.24.2
 - @standardnotes/event-store@1.3.5
 - @standardnotes/files-server@1.5.44
 - @standardnotes/scheduler-server@1.10.21
 - @standardnotes/syncing-server@1.6.61
 - @standardnotes/time@1.11.0
2022-09-06 10:10:20 +00:00
Karol Sójko
db8333a858 feat(time): add converting microseconds to time structure 2022-09-06 12:08:39 +02:00
20 changed files with 80 additions and 7 deletions

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.16.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.16.0...@standardnotes/api-gateway@1.16.1) (2022-09-06)
**Note:** Version bump only for package @standardnotes/api-gateway
# [1.16.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.15.12...@standardnotes/api-gateway@1.16.0) (2022-09-06)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.16.0",
"version": "1.16.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.24.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.24.1...@standardnotes/auth-server@1.24.2) (2022-09-06)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.24.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.24.0...@standardnotes/auth-server@1.24.1) (2022-09-06)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.24.1",
"version": "1.24.2",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.5](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.3.4...@standardnotes/event-store@1.3.5) (2022-09-06)
**Note:** Version bump only for package @standardnotes/event-store
## [1.3.4](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.3.3...@standardnotes/event-store@1.3.4) (2022-09-06)
**Note:** Version bump only for package @standardnotes/event-store

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.3.4",
"version": "1.3.5",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.5.44](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.5.43...@standardnotes/files-server@1.5.44) (2022-09-06)
**Note:** Version bump only for package @standardnotes/files-server
## [1.5.43](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.5.42...@standardnotes/files-server@1.5.43) (2022-09-06)
**Note:** Version bump only for package @standardnotes/files-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.5.43",
"version": "1.5.44",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.10.21](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.10.20...@standardnotes/scheduler-server@1.10.21) (2022-09-06)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.10.20](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.10.19...@standardnotes/scheduler-server@1.10.20) (2022-09-06)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.10.20",
"version": "1.10.21",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.6.61](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.6.60...@standardnotes/syncing-server@1.6.61) (2022-09-06)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.6.60](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.6.59...@standardnotes/syncing-server@1.6.60) (2022-09-06)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.6.60",
"version": "1.6.61",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.11.0](https://github.com/standardnotes/server/compare/@standardnotes/time@1.10.0...@standardnotes/time@1.11.0) (2022-09-06)
### Features
* **time:** add converting microseconds to time structure ([db8333a](https://github.com/standardnotes/server/commit/db8333a858ba0fa6750116967355d26e72b8c16d))
# [1.10.0](https://github.com/standardnotes/server/compare/@standardnotes/time@1.9.1...@standardnotes/time@1.10.0) (2022-09-05)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/time",
"version": "1.10.0",
"version": "1.11.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -1,4 +1,7 @@
export enum Time {
MicrosecondsInADay = 86_400_000_000,
MicrosecondsInAnHour = 3_600_000_000,
MicrosecondsInAMinute = 60_000_000,
MicrosecondsInASecond = 1_000_000,
MicrosecondsInAMillisecond = 1_000,
}

View File

@@ -0,0 +1,6 @@
export type TimeStructure = {
days: number
hours: number
minutes: number
seconds: number
}

View File

@@ -108,4 +108,13 @@ describe('Timer', () => {
it('should format date', () => {
expect(createTimer().formatDate(new Date('2021-03-29T08:00:05.233123Z'), 'YYYY-MM-DD')).toEqual('2021-03-29')
})
it('should convert microseconds to time structure', () => {
expect(createTimer().convertMicrosecondsToTimeStructure(1821050982073)).toEqual({
days: 21,
hours: 1,
minutes: 50,
seconds: 50,
})
})
})

View File

@@ -3,12 +3,33 @@ import * as utc from 'dayjs/plugin/utc'
import * as microtime from 'microtime'
import { Time } from './Time'
import { TimerInterface } from './TimerInterface'
import { TimeStructure } from './TimeStructure'
export class Timer implements TimerInterface {
constructor() {
dayjs.extend(utc)
}
convertMicrosecondsToTimeStructure(microseconds: number): TimeStructure {
const days = Math.floor(microseconds / Time.MicrosecondsInADay)
const hoursLeftOver = microseconds % Time.MicrosecondsInADay
const hours = Math.floor(hoursLeftOver / Time.MicrosecondsInAnHour)
const minutesLeftOver = microseconds % Time.MicrosecondsInAnHour
const minutes = Math.floor(minutesLeftOver / Time.MicrosecondsInAMinute)
const secondsLeftOver = microseconds % Time.MicrosecondsInAMinute
const seconds = Math.floor(secondsLeftOver / Time.MicrosecondsInASecond)
return {
days,
hours,
minutes,
seconds,
}
}
formatDate(date: Date, format: string): string {
return dayjs.utc(date).format(format)
}

View File

@@ -1,3 +1,5 @@
import { TimeStructure } from './TimeStructure'
export interface TimerInterface {
getTimestampInMicroseconds(): number
getTimestampInSeconds(): number
@@ -17,6 +19,7 @@ export interface TimerInterface {
convertMicrosecondsToSeconds(microseconds: number): number
convertMicrosecondsToStringDate(microseconds: number): string
convertMicrosecondsToDate(microseconds: number): Date
convertMicrosecondsToTimeStructure(microseconds: number): TimeStructure
formatDate(date: Date, format: string): string
dateWasNDaysAgo(date: Date): number
}

View File

@@ -1,3 +1,4 @@
export * from './Time/Time'
export * from './Time/Timer'
export * from './Time/TimerInterface'
export * from './Time/TimeStructure'