- format = format.replace(/((^|[^%])(%%)*)%f/, microsecond_replacement_string)
- // timezone seems to ignore any strings without any formatting directives,
- // and just return the time argument back instead of the string argument.
- // But we want the string argument, in case a user supplies a format string
- // which doesn't contain a formatting directive or is only using %f.
- if (format.indexOf("%") == -1) {
- return format
- }
- return tz(t, format)
- }
- export function _us(t: number): number {
- // From double-precision unix (millisecond) timestamp, get microseconds since
- // last second. Precision seems to run out around the hundreds of nanoseconds
- // scale, so rounding to the nearest microsecond should round to a nice
- // microsecond / millisecond tick.
- return Math.round(((t / 1000) % 1) * 1000000)
- }