Time & Duration refactor.

- Rename `TPTime` type to `time`.
- Rename `TPDuration` type to `duration`.
- Remove `TPTimestamp` type (in favour of `time`).
- Brand `time` type.
- Add `Time` and `Duration` static classes for functions that operate on
  time and duration types.
- Remove free functions like `toNs` and `fromNs`.

Change-Id: I7651b97e44ded76d23fe2f566da10690e80c47be
diff --git a/ui/src/frontend/tickmark_panel.ts b/ui/src/frontend/tickmark_panel.ts
index 874332c..8234caf 100644
--- a/ui/src/frontend/tickmark_panel.ts
+++ b/ui/src/frontend/tickmark_panel.ts
@@ -14,7 +14,7 @@
 
 import m from 'mithril';
 
-import {timestampOffset} from '../common/time';
+import {Time, timestampOffset} from '../common/time';
 
 import {TRACK_SHELL_WIDTH} from './css_constants';
 import {globals} from './globals';
@@ -51,7 +51,7 @@
       const offset = timestampOffset();
       const tickGen = new TickGenerator(visibleSpan, maxMajorTicks, offset);
       for (const {type, time} of tickGen) {
-        const px = Math.floor(map.tpTimeToPx(time));
+        const px = Math.floor(map.timeToPx(time));
         if (type === TickType.MAJOR) {
           ctx.fillRect(px, 0, 1, size.height);
         }
@@ -60,14 +60,14 @@
 
     const data = globals.searchSummary;
     for (let i = 0; i < data.tsStarts.length; i++) {
-      const tStart = data.tsStarts[i];
-      const tEnd = data.tsEnds[i];
+      const tStart = Time.fromRaw(data.tsStarts[i]);
+      const tEnd = Time.fromRaw(data.tsEnds[i]);
       if (!visibleSpan.intersects(tStart, tEnd)) {
         continue;
       }
       const rectStart =
-          Math.max(visibleTimeScale.tpTimeToPx(tStart), 0) + TRACK_SHELL_WIDTH;
-      const rectEnd = visibleTimeScale.tpTimeToPx(tEnd) + TRACK_SHELL_WIDTH;
+          Math.max(visibleTimeScale.timeToPx(tStart), 0) + TRACK_SHELL_WIDTH;
+      const rectEnd = visibleTimeScale.timeToPx(tEnd) + TRACK_SHELL_WIDTH;
       ctx.fillStyle = '#ffe263';
       ctx.fillRect(
           Math.floor(rectStart),
@@ -79,7 +79,8 @@
     if (index !== -1 && index < globals.currentSearchResults.tsStarts.length) {
       const start = globals.currentSearchResults.tsStarts[index];
       const triangleStart =
-          Math.max(visibleTimeScale.tpTimeToPx(start), 0) + TRACK_SHELL_WIDTH;
+          Math.max(visibleTimeScale.timeToPx(Time.fromRaw(start)), 0) +
+          TRACK_SHELL_WIDTH;
       ctx.fillStyle = '#000';
       ctx.beginPath();
       ctx.moveTo(triangleStart, size.height);