All files / lib/internal/http httpDateTime.ts

75% Statements 6/8
50% Branches 2/4
50% Functions 1/2
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 141x     1x 2x 2x 2x     1x        
import { none, Option } from "@reactive-js/core/lib/option";
import { HttpDateTime } from "./interfaces";
 
export const parseHttpDateTime = (v: string): Option<HttpDateTime> => {
  const asDate = new Date(v);
  const result = asDate.getTime();
  return v !== "" && !Number.isNaN(result) ? result : none;
};
 
export const httpDateTimeToString = (v: HttpDateTime): string => {
  const date = new Date(v);
  return date.toUTCString();
};