• Hannu Trey's avatar
    Re-detect the host time zone if requested by an embedder · f781f522
    Hannu Trey authored
    Add an enum argument to DateTimeConfigurationChangeNotification to
    control whether or not to redetect the host time zone. The default value
    kSkip doesn't cause redetecting so that callers do not need to change if
    they want the current behavior (e.g. Chromium).
    
    Note that the host time zone detection does not work when v8 is run
    inside a sandbox as in Chromium so that Chromium detects the host time
    zone outside the sandbox before calling
    DateTimeConfigurationChangeNotification. OTOH, other v8 embedders may
    find it more convenient for v8 to do the host time zone detection on
    their behalf. In that case, they can call the function with the new
    argument set to value kRedetect.
    
    Test:
    With PHP+V8Js on linux, execute:
    php -r '
      putenv("TZ=Europe/Helsinki");
      $v8 = new V8Js();
      $v8->executeString("print((new Date(0)).toString()+\"\\n\");");
      putenv("TZ=America/New_York");
      $v8->executeString("print((new Date(0)).toString()+\"\\n\");");'
    
    Result before modification:
    Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
    Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
    
    Result after modification:
    Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
    Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
    
    Result after V8JS is modified to use value kRedetect when calling
    
    Thu Jan 01 1970 02:00:00 GMT+0200 (Eastern European Standard Time)
    Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time)
    
    DateTimeConfigurationChangeNotification: 
    Change-Id: I005192dd42669a94f606a49baa9eafad3475b9fd
    Reviewed-on: https://chromium-review.googlesource.com/c/1449637Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
    Reviewed-by: 's avatarJungshik Shin <jshin@chromium.org>
    Commit-Queue: Jungshik Shin <jshin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#59613}
    f781f522
date.h 8.03 KB