AtlatestRepositorysigil-web-styles
1
{2
"module": "(sigil time)",3
"package": "sigil-stdlib",4
"source": "/home/daviwil/Projects/Code/sigil/sigil/packages/sigil-stdlib/src/sigil/time.sgl",5
"description": "(sigil time) - Time and Date Library\n\nTime and date operations including timestamps, high-resolution timing,\nand date/time formatting.\n\n## Current Time\n\n```scheme\n(import (sigil time))\n\n(current-second) ; => 1705330200.123\n(format-datetime (current-second)) ; => \"2025-01-15 14:30:00\"\n```\n\n## Component Access\n\n```scheme\n(let ((now (current-second)))\n (time-year now) ; => 2025\n (time-month now) ; => 1\n (time-day now) ; => 15\n (time-hour now) ; => 14\n (time-minute now) ; => 30\n (time-second now)) ; => 0\n```\n\n## Timing\n\n```scheme\n(with-timing \"my-operation\"\n (lambda () (heavy-computation)))\n; prints: my-operation: 0.523 seconds\n```",6
"exports": [7
{8
"name": "current-second",9
"kind": "procedure",10
"description": "Get current time as seconds since Unix epoch.\n\nReturns a real number with fractional seconds.\n\n```scheme\n(current-second) ; => 1705330200.123456\n```",11
"line": 9212
},13
{14
"name": "current-jiffy",15
"kind": "procedure",16
"description": "Get current time in jiffies (high-resolution timer).\n\nUse with `jiffies-per-second` to compute elapsed time.\n\n```scheme\n(current-jiffy) ; => 123456789\n```",17
"line": 10218
},19
{20
"name": "jiffies-per-second",21
"kind": "procedure",22
"description": "Get the number of jiffies per second.\n\n```scheme\n(jiffies-per-second) ; => 1000000000 (nanosecond precision)\n```",23
"line": 11024
},25
{26
"name": "time->list",27
"kind": "procedure",28
"description": "Convert a timestamp to a list of components.\n\nReturns `(second minute hour day month year weekday yearday dst?)`.",29
"line": 11630
},31
{32
"name": "list->time",33
"kind": "procedure",34
"description": "Convert a list of time components to a timestamp.",35
"line": 12036
},37
{38
"name": "time-second",39
"kind": "procedure",40
"description": "Get the seconds (0-59) from a timestamp.",41
"line": 12442
},43
{44
"name": "time-minute",45
"kind": "procedure",46
"description": "Get the minutes (0-59) from a timestamp.",47
"line": 12848
},49
{50
"name": "time-hour",51
"kind": "procedure",52
"description": "Get the hour (0-23) from a timestamp.",53
"line": 13254
},55
{56
"name": "time-day",57
"kind": "procedure",58
"description": "Get the day of month (1-31) from a timestamp.",59
"line": 13660
},61
{62
"name": "time-month",63
"kind": "procedure",64
"description": "Get the month (1-12) from a timestamp.",65
"line": 14066
},67
{68
"name": "time-year",69
"kind": "procedure",70
"description": "Get the year from a timestamp.",71
"line": 14472
},73
{74
"name": "time-weekday",75
"kind": "procedure",76
"description": "Get the day of week (0=Sunday, 6=Saturday) from a timestamp.",77
"line": 14878
},79
{80
"name": "time-yearday",81
"kind": "procedure",82
"description": "Get the day of year (1-366) from a timestamp.",83
"line": 15284
},85
{86
"name": "time-dst?",87
"kind": "procedure",88
"description": "Check if daylight saving time is in effect for a timestamp.",89
"line": 15690
},91
{92
"name": "time-utc-offset",93
"kind": "procedure",94
"description": "Get the UTC offset in seconds for the local timezone.\n\n```scheme\n(time-utc-offset) ; => -18000 (EST = -5 hours)\n```",95
"line": 16496
},97
{98
"name": "time-utc-offset-at",99
"kind": "procedure",100
"description": "Get the UTC offset in seconds for a specific timestamp.\n\nUnlike `time-utc-offset` which returns the offset for \"right now\",\nthis returns the offset that applies at the given Unix timestamp.\nEssential for correct DST handling when parsing dates in different\nseasons than the current date.\n\n```scheme\n(time-utc-offset-at 1711756800) ; => offset at that specific moment\n```",101
"line": 177102
},103
{104
"name": "sleep",105
"kind": "procedure",106
"description": "Sleep for a given number of seconds.\n\nWhen running inside an async context (`with-async`), yields to the\nscheduler so other tasks can run during the sleep. Outside async\ncontext, falls back to a blocking kernel sleep.\n\n```scheme\n(sleep 0.5) ; sleep 500ms\n(sleep 2) ; sleep 2 seconds\n```",107
"line": 190108
},109
{110
"name": "time-elapsed",111
"kind": "procedure",112
"description": "Measure elapsed time for evaluating a thunk.\n\nReturns `(values result elapsed-seconds)`.\n\n```scheme\n(let-values (((result elapsed) (time-elapsed (lambda () (fib 30)))))\n (format \"Result: ~a in ~a seconds\" result elapsed))\n```",113
"line": 207114
},115
{116
"name": "with-timing",117
"kind": "procedure",118
"description": "Execute thunk and print timing information.\n\nReturns the result of the thunk.\n\n```scheme\n(with-timing \"compilation\"\n (lambda () (compile-file \"main.sgl\")))\n; prints: compilation: 0.523 seconds\n```",119
"line": 224120
},121
{122
"name": "format-time",123
"kind": "procedure",124
"description": "Format a timestamp as HH:MM:SS string.\n\nPass `#t` as second argument to format in UTC.\n\n```scheme\n(format-time (current-second)) ; => \"14:30:00\"\n(format-time (current-second) #t) ; => \"19:30:00\" (UTC)\n```",125
"line": 248126
},127
{128
"name": "format-date",129
"kind": "procedure",130
"description": "Format a timestamp as YYYY-MM-DD string.\n\n```scheme\n(format-date (current-second)) ; => \"2025-01-15\"\n```",131
"line": 261132
},133
{134
"name": "format-datetime",135
"kind": "procedure",136
"description": "Format a timestamp as YYYY-MM-DD HH:MM:SS string.\n\n```scheme\n(format-datetime (current-second)) ; => \"2025-01-15 14:30:00\"\n```",137
"line": 274138
},139
{140
"name": "pad-zero",141
"kind": "procedure",142
"description": "Pad number with leading zero if < 10.\n(pad-zero 5) -> \"05\"\n(pad-zero 15) -> \"15\"",143
"line": 284144
},145
{146
"name": "parse-iso-date",147
"kind": "procedure",148
"description": "Parse an ISO 8601 date string into a list of components.\n\nAccepts both full timestamps `\"YYYY-MM-DDTHH:MM:SSZ\"` and\ndate-only strings `\"YYYY-MM-DD\"`. Returns a list of\n`(year month day hour minute second)`.\n\n```scheme\n(parse-iso-date \"2024-01-15T12:30:00Z\")\n; => (2024 1 15 12 30 0)\n(parse-iso-date \"2024-01-15\")\n; => (2024 1 15 0 0 0)\n```",149
"line": 303150
},151
{152
"name": "format-iso-date",153
"kind": "procedure",154
"description": "Format a date component list back to an ISO 8601 UTC string.\n\nTakes a list `(year month day hour minute second)` and returns\n`\"YYYY-MM-DDTHH:MM:SSZ\"`.\n\n```scheme\n(format-iso-date '(2024 1 15 12 30 0))\n; => \"2024-01-15T12:30:00Z\"\n```",155
"line": 327156
},157
{158
"name": "days-in-month",159
"kind": "procedure",160
"description": "Return the number of days in a given month, handling leap years.\n\n```scheme\n(days-in-month 2024 2) ; => 29 (leap year)\n(days-in-month 2023 2) ; => 28\n(days-in-month 2024 7) ; => 31\n```",161
"line": 350162
},163
{164
"name": "add-days",165
"kind": "procedure",166
"description": "Add a number of days to a date component list.\n\nTakes a list `(year month day hour minute second)` and a day count\n(positive or negative), returning a new date list with month/year\nboundaries handled correctly.\n\n```scheme\n(add-days '(2024 1 30 0 0 0) 5)\n; => (2024 2 4 0 0 0)\n```",167
"line": 372168
},169
{170
"name": "date-compare",171
"kind": "procedure",172
"description": "Compare two date component lists element by element.\n\nReturns `-1` if `a` is earlier, `0` if equal, `1` if `a` is later.\n\n```scheme\n(date-compare '(2024 1 15 0 0 0) '(2024 6 1 0 0 0)) ; => -1\n```",173
"line": 404174
}175
]176
}