On Thursday, February 21, 2019 at 11:16:00 PM UTC-5, Jon Zeppieri wrote:
>
>
>
> On Thu, Feb 21, 2019 at 10:12 PM Brian Adkins <lojic...@gmail.com 
> <javascript:>> wrote:
>
>> On Thursday, February 21, 2019 at 9:54:23 PM UTC-5, Jon Zeppieri wrote:
>>>
>>>
>>>
>>> On Thu, Feb 21, 2019 at 9:48 PM Brian Adkins <lojic...@gmail.com> wrote:
>>>
>>>> On Thursday, February 21, 2019 at 9:35:58 PM UTC-5, Brian Adkins wrote:
>>>>>
>>>>> On Thursday, February 21, 2019 at 9:26:07 PM UTC-5, Brian Adkins wrote:
>>>>>>
>>>>>> I'm using the (today) function from the gregor library. It was 
>>>>>> returning tomorrow instead of today, so I thought the problem was the 
>>>>>> timezone on my Ubuntu server. I configured the timezone to be US/Eastern 
>>>>>> via: sudo dpkg-reconfigure tzdata
>>>>>>
>>>>>> Now the date command returns:  Thu Feb 21 21:23:43 EST 2019   as 
>>>>>> expected.
>>>>>>
>>>>>> Unfortunately, (system-tzid) returns:  "Etc/UTC"
>>>>>>
>>>>>> So, gregor's (today) still returns tomorrow (since it's so late).
>>>>>>
>>>>>> Anyone know how to get (system-tzid) to return the correct value on 
>>>>>> Ubuntu?
>>>>>>
>>>>>
>>>>> Some more info:
>>>>>
>>>>> /etc/localtime is linked as:  localtime -> 
>>>>> /usr/share/zoneinfo/US/Eastern 
>>>>>
>>>>
>>>> I reinvoked sudo dpkg-reconfigure tzdata  and chose America/New_York  
>>>> instead of  US/Eastern, but I still get the default "Etc/UTC" from 
>>>> (system-tzid) 
>>>>
>>>
>>>
>>> Huh. Could you do the following and tell me what you get?
>>>
>>> > (require tzinfo/private/generics)
>>> > (require tzinfo/private/zoneinfo)
>>> > (define zi (make-zoneinfo-source))
>>> > (zoneinfo-dir zi)
>>> "/usr/share/zoneinfo"
>>> > (detect-system-tzid zi)
>>> "America/New_York"
>>>
>>
>> > (require tzinfo/private/generics)
>> > (require tzinfo/private/zoneinfo)
>> > (define zi (make-zoneinfo-source))
>> > (zoneinfo-dir zi)
>> "/usr/share/zoneinfo"
>> > (detect-system-tzid zi)
>> #f
>>
>> Also:
>>
>> $ ls -l /etc/localtime
>> lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
>> /usr/share/zoneinfo/America/New_York
>>
>> $ cat /etc/timezone
>> America/New_York
>>  
>>
>
> Thanks.
>
> Okay, so first I figured that the problem was probably due to the weird 
> way that I try to discover the target of an /etc/timezone symlink. (Racket 
> doesn't provide that functionality, as far as I could tell at the time, and 
> I guess I wanted to avoid the FFI? Even though I used it for Windows? My 
> memory fails me.)
>
> But, if that method fails, it also tries getting the value from 
> /etc/timezone, which you noted, is set correctly. And that method of 
> getting the timezone is really simple. It just reads the file. So... hmm. 
> Okay, let's do this exhaustively.
>
> 1. Verify that (system-type) is 'unix. (Just to make sure we check 
> everything.)
>
> 2. In DrRacket, in the definitions window, put the following:
> ```
> #lang racket/base
>
> (require tzinfo/private/zoneinfo)
> ```
> 3. Right click on `tzinfo/private/zoneinfo` and select "Open zoneinfo.rkt."
>
> 4. In the new DrRacket window that contains the source of zoneinfo.rkt, 
> click "Run."
>
> 5. Then, in the interaction pane, do:
> > (define zi (make-zoneinfo-source))
> > (tzinfo-has-tzid? zi "America/New_York")
> #t
>
> If this is #f, that would be bad, and you can stop right there.
>
> 6. Next:
> > (find-zoneinfo-directory default-zoneinfo-search-path)
> "/usr/share/zoneinfo"
>
> If you don't get the same values for this, that would be odd.
>
> 7.
> > (detect-tzid/unix (zoneinfo-dir zi)
>                     (find-zoneinfo-directory default-zoneinfo-search-path)
>                     (tzinfo->all-tzids zi))
> "America/New_York"
>
> I expect you'll either get #f here or else you'll get a string but it 
> won't be a valid IANA time zone name.
>
> 8. Near the top of zoneinfo.rkt, you'll see a require line for 
> "os/unix.rkt." Right click that and open the file. Run it.
>
> 9. In the interactions pane:
> > (tzid-from-env)
> #f
>
> (If this isn't #f, and it also isn't an valid IANA time zone id, that 
> would be the problem.)
>
> 10.
> > (tzid-from-/etc/timezone)
> #f
>
> Based on what you wrote above, I expect you to get "America/New_York" 
> here. (I get #f, but I'm on OS X.)
>
> ===
>
> I think you'll have to get unexpected results from one of these, and that 
> should help us figure out the problem.
> My best guess right now is that detect-tzid/unix will return a string that 
> isn't a valid IANA tzid. And that might be because you have the TZ 
> environment variable set. 
>
> Thank you for helping me track down this bug. If my guess is correct, I 
> need to make a slight change to the code.
>
> (Summary: detect-tzid/unix tries a few different methods for determining 
> the system time zone, and it stops when any one of them is non-#f. But the 
> returned string is only validated against the list of IANA zones 
> afterwards, so if any of those methods returns a string that isn't a valid 
> time zone, it won't try any of the other methods.)
>
>
Yes, I think we found the problem:

$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 36 Feb 21 21:45 /etc/localtime -> 
/usr/share/zoneinfo/America/New_York
deploy@ip-172-31-10-34:~$ ls -l /usr/share/zoneinfo/America/New_York
lrwxrwxrwx 1 root root 13 Jan  1 00:05 /usr/share/zoneinfo/America/New_York 
-> ../posixrules
 

$ racket
Welcome to Racket v7.1.
> (require racket/enter)
> (require tzinfo/private/zoneinfo)
> (enter! tzinfo/private/zoneinfo)
<pkgs>/tzinfo/tzinfo/private/zoneinfo> (define zi (make-zoneinfo-source))
<pkgs>/tzinfo/tzinfo/private/zoneinfo> (tzinfo-has-tzid? zi 
"America/New_York")
#t
<pkgs>/tzinfo/tzinfo/private/zoneinfo> (find-zoneinfo-directory 
default-zoneinfo-search-path)
"/usr/share/zoneinfo"
<pkgs>/tzinfo/tzinfo/private/zoneinfo> (detect-tzid/unix (zoneinfo-dir zi)
                                                          
 (find-zoneinfo-directory default-zoneinfo-search-path)
                                                          
 (tzinfo->all-tzids zi))
"posixrules"
 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to