Pass io to zeit.instant only when needed #59
Open
der-teufel-programming wants to merge 10 commits intorockorager:0.16from
Open
Pass io to zeit.instant only when needed #59der-teufel-programming wants to merge 10 commits intorockorager:0.16from
io to zeit.instant only when needed #59der-teufel-programming wants to merge 10 commits intorockorager:0.16from
Conversation
Add new EnvConfig struct to replace ?*const std.process.EnvMap parameter. This struct has two optional fields: tz and tzdir, which are the only env vars used in the codebase (TZ and TZDIR). Amp-Thread-ID: https://ampcode.com/threads/T-019c1943-dfe8-738f-bb29-33f5535caba6 Co-authored-by: Amp <amp@ampcode.com>
Change local(alloc, maybe_env) to local(alloc, io, env) to use the new
EnvConfig struct and Zig 0.16's io parameter for file readers.
- Replace ?*const std.process.EnvMap with EnvConfig parameter
- Use env.tz instead of env.get("TZ")
- Pass io to f.reader() as required by Zig 0.16
- Update localFromEnv call to pass io parameter
Amp-Thread-ID: https://ampcode.com/threads/T-019c1944-707c-729d-bd53-54f720ca9a4b
Co-authored-by: Amp <amp@ampcode.com>
Update localFromEnv() to accept std.Io and EnvConfig parameters.
Update loadTimeZone() to accept std.Io and EnvConfig, replacing the
optional EnvMap parameter. Change env.get("TZDIR") to env.tzdir.
Fix f.reader() calls to use the new two-argument API.
Amp-Thread-ID: https://ampcode.com/threads/T-019c1944-ff40-7226-a919-97166bf2902d
Co-authored-by: Amp <amp@ampcode.com>
Add io parameter to instant() function signature and replace the removed std.time.nanoTimestamp() with std.Io.Clock.now(.real, io). Update all callers in tests to pass std.testing.io. Amp-Thread-ID: https://ampcode.com/threads/T-019c1945-d480-712c-b7cf-944f207f6048 Co-authored-by: Amp <amp@ampcode.com>
Update test code to use Zig 0.16's new Writer API: - Replace std.io.fixedBufferStream(&buf) with std.Io.Writer.fixed(&buf) - Replace fbs.writer() calls with direct &writer references - Replace fbs.reset() with writer.end = 0 - Replace fbs.getWritten() with writer.buffered() Affects fmtStrftime and gofmt tests. Amp-Thread-ID: https://ampcode.com/threads/T-019c1948-1e3c-71c0-acbc-362fd1c33a22 Co-authored-by: Amp <amp@ampcode.com>
- Replace std.io.Reader with std.Io.Reader in TZInfo.parse - Replace writeByteNTimes with splatByteAll - Update local() call in Instant test to use new 3-arg signature - Replace std.io.null_writer with std.Io.Writer.Discarding - Replace ArrayList.writer() with std.Io.Writer.Allocating in tests - Update loadTimeZone calls to pass std.testing.io and EnvConfig Amp-Thread-ID: https://ampcode.com/threads/T-019c194a-2af5-75d1-8b83-8635b95d7d7e Co-authored-by: Amp <amp@ampcode.com>
Replace deprecated std.fs file and directory operations with their std.Io equivalents for Zig 0.16 compatibility: - std.fs.cwd().openFile -> std.Io.Dir.cwd().openFile(io, ...) - std.fs.openDirAbsolute -> std.Io.Dir.cwd().openDir(io, ...) - std.fs.Dir -> std.Io.Dir - f.close() -> f.close(io) - dir.close() -> dir.close(io) - dir.openFile(...) -> dir.openFile(io, ...) Amp-Thread-ID: https://ampcode.com/threads/T-019c194f-494e-7058-9236-403b366f06ad Co-authored-by: Amp <amp@ampcode.com>
…formatting `timeFmt` supports both `gofmt` and `strftime`
…an `now` requires it
Owner
|
Is there a pattern emerging here? I feel like passing it in on the config is not how this would be done with an allocator. What do you think about making it a nullable param?
|
I think it might be nicer to have two functions, one with a config, and one without but it takes an fn instant(config: Config)
fn instantNow(io: std.Io, tz: TimeZone)The new |
Contributor
Author
|
I agree that separating creating |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No source other than
nowrequires it