|
12 | 12 | [taoensso.encore :as enc] |
13 | 13 | [taoensso.tufte :as tufte]) |
14 | 14 | (:import (java.io Closeable BufferedInputStream InputStream) |
15 | | - (org.apache.poi.ss.usermodel RichTextString Sheet Cell Row Workbook) |
| 15 | + (org.apache.poi.ss.usermodel RichTextString Sheet Cell Row Workbook DateUtil) |
16 | 16 | (java.util Date Calendar) |
| 17 | + (java.time LocalDate LocalDateTime) |
17 | 18 | (org.apache.poi.ss.util CellRangeAddress) |
18 | 19 | (org.apache.poi.xssf.streaming SXSSFWorkbook) |
19 | 20 | (org.apache.poi.xssf.usermodel XSSFWorkbook))) |
|
91 | 92 | [^Cell cell data] |
92 | 93 | ;; These types are allowed natively |
93 | 94 | (if-type |
94 | | - [data [Boolean Calendar String Date Double RichTextString]] |
| 95 | + [data [Boolean Calendar String Date LocalDate LocalDateTime Double RichTextString]] |
95 | 96 | (doto cell (.setCellValue data)) |
96 | 97 |
|
97 | 98 | ;; Apache POI requires that numbers be doubles |
|
309 | 310 | ; the template sheet to overwrite completely |
310 | 311 | sh (sheet-writer w "raw")] |
311 | 312 |
|
312 | | - (doseq [header ["Date" ; use the same headers as in the template |
| 313 | + (doseq [header ["Date" |
313 | 314 | "Webserver Uptime" |
314 | 315 | "REST API Uptime" |
315 | | - "WebSocket API Uptime"]] |
| 316 | + "WebSocket API Uptime" |
| 317 | + "Local Datetime" |
| 318 | + "Local Date"]] |
316 | 319 | (write! sh header)) |
317 | 320 |
|
318 | 321 | (newline! sh) |
|
322 | 325 | one-hour (* 1000 60 60)] |
323 | 326 | (dotimes [i 99] |
324 | 327 | (let [row-ts (+ start-ts (* i one-hour)) |
325 | | - ymd {:data-format :ymd :alignment :left}] |
326 | | - (write! sh (Date. ^long row-ts) ymd 1 1)) |
327 | | - |
328 | | - ; random uptime values |
329 | | - (write! sh (- 1.0 (rand 0.25))) |
330 | | - (write! sh (- 1.0 (rand 0.25))) |
331 | | - (write! sh (- 1.0 (rand 0.25))) |
| 328 | + ymd {:data-format :ymd :alignment :left} |
| 329 | + dt {:data-format :datetime :alignment :left}] |
| 330 | + (write! sh (Date. ^long row-ts) ymd 1 1) |
| 331 | + |
| 332 | + ; random uptime values |
| 333 | + (write! sh (- 1.0 (rand 0.25))) |
| 334 | + (write! sh (- 1.0 (rand 0.25))) |
| 335 | + (write! sh (- 1.0 (rand 0.25))) |
| 336 | + |
| 337 | + ; LocalDate / LocalDateTime value |
| 338 | + (write! sh (DateUtil/toLocalDateTime (Date. ^long row-ts)) dt 1 1) |
| 339 | + (write! sh (.toLocalDate (DateUtil/toLocalDateTime (Date. ^long row-ts))) ymd 1 1)) |
332 | 340 | (newline! sh)))))) |
333 | 341 |
|
334 | 342 |
|
|
0 commit comments