rename humanTimestamp to getTimeFromTimestamp and add a test

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
Adam Warner
2019-11-25 20:39:09 +00:00
parent fa90f905e9
commit b9709a0a91
3 changed files with 22 additions and 3 deletions
+2 -2
View File
@@ -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 = {
+19
View File
@@ -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");
});
});
+1 -1
View File
@@ -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();