Skip to content

Conversation

@alex-pancho
Copy link

@alex-pancho alex-pancho commented Jun 16, 2018

winfix

@Balajanovski
Copy link

Balajanovski commented Apr 28, 2020

When will this be merged? @PiotrDabkowski

Piotr Dabkowski and others added 21 commits September 18, 2020 10:47
Remove nightly python tag to prevent unrelated build errors (eg due to numpy not installing).
Makes it possible to load timestamps starting from Jan 01 1900 rather than Jan 01 1970

console.log(new Date(70, 0, 1, 0, 0, 0));
console.log(new Date(Date.UTC(70, 0, 1, 6, 0, 0)));

console.log(new Date(0, 0, 1, 0, 0, 0));
console.log(new Date(Date.UTC(0, 0, 1, 6, 0, 0)));
This was found in issue 215 - loading ssf.js in Windows will result in an exception in DaylightSavingTA causing it to return a fixed value and display this message:

Warning: Invalid datetime date, assumed DST time, may be inaccurate...

Here is the trace from Python 3.8.5:
Traceback (most recent call last):
  File "test.py", line 28, in <module>
    context.execute(js)
  File "C:\Python38\Js2Py-master\js2py\evaljs.py", line 199, in execute
    exec (compiled, self._context)
  File "<EvalJS snippet>", line 2174, in <module>
  File "C:\Python38\Js2Py-master\js2py\base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "C:\Python38\Js2Py-master\js2py\base.py", line 1464, in call
    return Js(self.code(*args))
  File "<EvalJS snippet>", line 1541, in PyJs_make_ssf_0_
  File "C:\Python38\Js2Py-master\js2py\constructors\jsdate.py", line 149, in date_constructor
    return date_constructor2(*args)
  File "C:\Python38\Js2Py-master\js2py\constructors\jsdate.py", line 181, in date_constructor2
    LocalToUTC(MakeDate(MakeDay(y, m, dt), MakeTime(h, mi, sec, mili))))
  File "C:\Python38\Js2Py-master\js2py\constructors\time_helpers.py", line 54, in LocalToUTC
    return t - LocalTZA - DaylightSavingTA(t - LocalTZA)
  File "C:\Python38\Js2Py-master\js2py\constructors\time_helpers.py", line 39, in DaylightSavingTA
    LOCAL_ZONE.dst(datetime.datetime.utcfromtimestamp(
OSError: [Errno 22] Invalid argument
-> Refactored a little bit to avoid repetition
-> Leaving the explicit + ('',) because I think it shows the intent better
future releases of setuptools will not support "description-file"

'''/usr/lib/python3.9/site-packages/setuptools/dist.py:642:
UserWarning: Usage of dash-separated 'description-file'
will not be supported in future versions. Please use the
underscore name 'description_file' instead'''
warning discovered on setuptools, version 56.0.0

Signed-off-by: Maciej Barć <xgqt@riseup.net>
Function translate_file uses function write_file_contents. However, function write_file_contents doesn't write Python code while using UTF-8 to encode. It will cause problems after translate JS file with special strings ( e.g., Chinese) to Python file. Error will be raised when importing objects from the Python file.
Just like function get_file_contents, used codecs.open to fix the problem
These tests now pass on both the translator and the VM:

- String/prototype/replace 15.5.4.11_A2_T3
- String/prototype/replace 15.5.4.11_A2_T8

See https://262.ecma-international.org/5.1/#sec-15.5.4.11
for details on this replacement string value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.