Skip to content

Commit

Permalink
std/time: use sys package for environment variable lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Nov 25, 2024
1 parent c4ce1ee commit 27adc85
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions std/time/zoneinfo_unix.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
// See tzfile(5), https://en.wikipedia.org/wiki/Zoneinfo,
// and ftp://munnari.oz.au/pub/oldtz/

use integ "std/jule/integrated"

cpp unsafe fn getenv(name: *integ::Char): *integ::Char
cpp unsafe fn setenv(name: *integ::Char, value: *integ::Char, overwrite: int): int
use "std/sys"

// Many systems use /usr/share/zoneinfo, Solaris 2 has
// /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ,
Expand All @@ -31,7 +28,7 @@ fn initLocal() {
// /usr/share/zoneinfo/foo will be used.

mut tz := "TZ\000"
tz = unsafe { integ::BytePtrToStr((*byte)(cpp.getenv((*integ::Char)(&tz[0])))) }
tz, _ = unsafe { sys::Getenv(&tz[0]) }
match {
| len(tz) == 0:
mut z, ok := loadLocation("localtime", ["/etc"])
Expand Down

0 comments on commit 27adc85

Please sign in to comment.