mirror of
https://github.com/gosticks/web.git
synced 2026-08-12 12:10:20 +00:00
rename humanTimestamp to getTimeFromTimestamp and add a test
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
import React, { Component } from "react";
|
||||
import { animateScroll } from "react-scroll";
|
||||
import { WithAPIData } from "../common/WithAPIData";
|
||||
import { humanTimestamp } from "../../util/dateUtils";
|
||||
import { getTimeFromTimestamp } from "../../util/dateUtils";
|
||||
import api from "../../util/api";
|
||||
|
||||
export interface LiveLogProps {
|
||||
@@ -44,7 +44,7 @@ class LiveLog extends Component<LiveLogProps, {}> {
|
||||
nextId = this.props.nextID;
|
||||
|
||||
log.map(item =>
|
||||
logHistory.push(humanTimestamp(item.timestamp) + " " + item.message)
|
||||
logHistory.push(getTimeFromTimestamp(item.timestamp) + " " + item.message)
|
||||
);
|
||||
|
||||
const outputStyle = {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2019 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* Web Interface
|
||||
* Date/Time utility tests
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
import { getTimeFromTimestamp } from "../dateUtils";
|
||||
|
||||
const timestamp = 1574713854;
|
||||
|
||||
describe("humanTimestamp", () => {
|
||||
it("returns the time 20:30:54 from the input 1574713854", () => {
|
||||
expect(getTimeFromTimestamp(timestamp)).toEqual("20:30:54");
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
export function humanTimestamp(input: number) {
|
||||
export function getTimeFromTimestamp(input: number) {
|
||||
var date = new Date(input * 1000);
|
||||
var hours = date.getHours();
|
||||
var minutes = "0" + date.getMinutes();
|
||||
|
||||
Reference in New Issue
Block a user