(t?: number | string)
| 170 | * Get Unix's timestamp in seconds. |
| 171 | */ |
| 172 | export function timestamp(t?: number | string): number | Date { |
| 173 | if (t) { |
| 174 | // convert timestamp to Date |
| 175 | // timestamp(timestampValue) |
| 176 | let v: number; |
| 177 | if (typeof t === 'string') { |
| 178 | v = Number(t); |
| 179 | } else { |
| 180 | v = t; |
| 181 | } |
| 182 | if (String(v).length === 10) { |
| 183 | v *= 1000; |
| 184 | } |
| 185 | return new Date(v); |
| 186 | } |
| 187 | // get current timestamp |
| 188 | return Math.round(Date.now() / 1000); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Parse timestamp to Date |
no outgoing calls
no test coverage detected
searching dependent graphs…