Skip to content

Commit

Permalink
Merge pull request #924 from mathics/SystemTimeZone
Browse files Browse the repository at this point in the history
Add SystemTimeZone, adjust TimeZone..
  • Loading branch information
GarkGarcia authored Sep 27, 2020
2 parents 9e88fad + 2f3f4c7 commit 3f33c64
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ New features:
- option ``--full-form`` (``-F``) on ``mathics`` to parsed ``FullForm`` of input expressions
- ``Environment``
- ``System`Byteordering`` ``System`Environemnt`` #859
- ``SystemTimeZone`` and correct ``TimeZone`` #924

Ehancements and Bug fixes:

Expand Down
15 changes: 8 additions & 7 deletions mathics/builtin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from mathics.builtin import (
algebra, arithmetic, assignment, attributes, calculus, combinatorial, compilation,
comparison, control, datentime, diffeqns, evaluation, exptrig, functional,
graphics, graphics3d,
graphics, graphics3d,
image, inout, integer, iohooks, linalg, lists, logic,
manipulate, quantities, numbertheory, numeric, options, patterns,
plot, physchemdata, randomnumbers, recurrence, specialfunctions, scoping,
manipulate, quantities, numbertheory, numeric, options, patterns,
plot, physchemdata, randomnumbers, recurrence, specialfunctions, scoping,
strings, structure, system, tensors, xmlformat, optimization)

from mathics.builtin.base import (
Expand All @@ -19,10 +19,10 @@
modules = [
algebra, arithmetic, assignment, attributes, calculus, combinatorial, compilation,
comparison, control, datentime, diffeqns, evaluation, exptrig, functional,
graphics, graphics3d,
image, inout, integer, iohooks, linalg, lists, logic,
manipulate, quantities, numbertheory, numeric, options, patterns,
plot, physchemdata, randomnumbers, recurrence, specialfunctions, scoping,
graphics, graphics3d,
image, inout, integer, iohooks, linalg, lists, logic,
manipulate, quantities, numbertheory, numeric, options, patterns,
plot, physchemdata, randomnumbers, recurrence, specialfunctions, scoping,
strings, structure, system, tensors, xmlformat, optimization]

if ENABLE_FILES_MODULE:
Expand Down Expand Up @@ -120,6 +120,7 @@ def contribute(definitions):
definitions.get_attributes('System`$Post').clear()
definitions.get_attributes('System`$PrePrint').clear()
definitions.get_attributes('System`$SyntaxHandler').clear()
definitions.get_attributes('System`$TimeZone').clear()
definitions.get_attributes('System`$UseSansSerif').clear()
from mathics.core.expression import ensure_context
from mathics.core.parser import all_operator_names
Expand Down
35 changes: 32 additions & 3 deletions mathics/builtin/datentime.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,24 @@ def apply_spec(self, epochtime, evaluation):
return from_python(total_seconds(tdelta))


class SystemTimeZone(Predefined):
"""
<dl>
<dt>'$SystemTimeZone'
<dd> gives the current time zone for the computer system on which Mathics is being run.
</dl>
>> $SystemTimeZone
= ...
"""

name = '$SystemTimeZone'
value = Real(-time.timezone / 3600.)

def evaluate(self, evaluation):
return self.value


class TimeZone(Predefined):
"""
<dl>
Expand All @@ -549,10 +567,21 @@ class TimeZone(Predefined):
= ...
"""

name = '$TimeZone'
name = "$TimeZone"
value = SystemTimeZone.value.copy()

def evaluate(self, evaluation):
return Real(-time.timezone / 3600.)
rules = {
"$TimeZone": str(value),
}

def apply(self, lhs, rhs, evaluation):
'lhs_ = rhs_'

self.assign(lhs, rhs, evaluation)
return rhs

def evaluate(self, evaluation) -> Real:
return self.value


class TimeUsed(Builtin):
Expand Down
3 changes: 1 addition & 2 deletions mathics/builtin/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RecursionLimit(Predefined):
'$RecursionLimit': str(value),
}

def evaluate(self, evaluation):
def evaluate(self, evaluation) -> Integer:
return Integer(self.value)


Expand Down Expand Up @@ -490,4 +490,3 @@ class Exit(Builtin):
# 'Quit[n_Integer]': 'Exit[n]',
# 'Quit': 'Exit',
# }

1 change: 0 additions & 1 deletion mathics/core/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import mpmath
import math
import re
from itertools import chain

import typing
from typing import Any
Expand Down

0 comments on commit 3f33c64

Please sign in to comment.