Time lib and http

This commit is contained in:
allexanderbergmns
2026-08-25 15:39:44 +02:00
parent 4ccc8a0f95
commit 5daadce7a9
11 changed files with 310 additions and 7 deletions
+23
View File
@@ -0,0 +1,23 @@
// http.vr — HTTP client (part of the VuurRaaf stdlib).
//
// import http
// let res = http.get("https://api.example.com/status")
// println(str(res.status))
// println(res.body)
//
// http.get / http.post return a struct with `status` (int) and `body`
// (string). Network failures (DNS, refused, timeout) throw, so they can be
// caught with try/catch; HTTP-level errors (404, 500) are normal responses.
fn get(url) {
return http_get(url)
}
fn post(url, data) {
return http_post(url, data)
}
// get_text returns just the response body as a string.
fn get_text(url) {
return http_get(url).body
}
+36
View File
@@ -0,0 +1,36 @@
// time.vr — date/time helpers (part of the VuurRaaf stdlib).
//
// import time
// println(time.format(time.now(), "YYYY-MM-DD HH:mm:ss"))
// println(time.format(time.now(), "YYYY-MM-DD"))
//
// Tokens follow the Moment.js style: YYYY (year), MM (month), DD (day),
// HH (24h hour), mm (minute), ss (second), plus literals like "-", ":".
// All values are Unix epoch seconds. `time.parse` accepts common ISO
// timestamps like "2026-08-25 14:03:22".
fn now() {
return now()
}
fn ms() {
return time_ms()
}
fn format(t, spec) {
return format_time(t, spec)
}
fn parse(s) {
return parse_time(s)
}
// date(t) formats just the calendar day: YYYY-MM-DD.
fn date(t) {
return format_time(t, "YYYY-MM-DD")
}
// clock(t) formats just the wall clock: HH:mm:ss.
fn clock(t) {
return format_time(t, "HH:mm:ss")
}