Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/pendulum'
Browse files Browse the repository at this point in the history
  • Loading branch information
ConceptJunkie committed Dec 20, 2023
2 parents 6b5649f + b1bfa39 commit 9c78c93
Show file tree
Hide file tree
Showing 22 changed files with 609 additions and 488 deletions.
28 changes: 13 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
arrow>=1.2.2
convertdate>=2.3.2
python-dateutil>=2.8.2
ephem>=4.1.3
ephem>=4.1.4
ethiopian-date-converter>=0.1.5
geopy>=2.2.0
gmpy2>=2.0.8
geopy>=2.3.0
gmpy2>=2.1.5
hyperop>=1.1
importlib_resources>=5.4.0
joblib>=1.2.0
mpmath>=1.2.1
numpy>=1.19.5
pytz>=2021.3
importlib_resources>=6.0.1
joblib>=1.3.2
mpmath>=1.3.0
numpy>=1.23.5
pendulum>=2.1.2
pyreadline3
rpnChiladaData>=1.1.0
setuptools>=56.1.0
setuptools>=65.5.1
skyfield>=1.42
timezonefinder>=5.2.0
types-python-dateutil>=2.8.9
types-pytz>=2021.3.4
tzlocal>=4.1
wheel>=0.37.0
tzlocal>=4.2
tzwhere>=3.0.3
wheel>=0.41.2
48 changes: 32 additions & 16 deletions rpn/makeHelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def makeCommandExample( command, indent=0, slow=False ):
'decagonal_pentagonal', 'decagonal_hexagonal', 'decagonal_heptagonal',
'decagonal_octagonal', 'decagonal_nonagonal' operators.

Added the 'distance' operator and changed geocoding lookup to use Nominatim
Added the 'distance' operator and changed geocoding lookUp to use Nominatim
instead of Google, because the Google lookup (provided by ephem) suddenly
stopped working.

Expand Down Expand Up @@ -1387,6 +1387,22 @@ def makeCommandExample( command, indent=0, slow=False ):
Added the 'random_prime' and 'random_primes' operators.

And the usual bug fixes and pylint fixes.

9.0.0

After a long hiatus, rpnChilada is back and the long-running timezone issues
have finally been put to rest. 9.0 replaces the arrow library with the
pendulum library for date and time handling.

'to_time_zone' has been renamed to 'convert_time_zone'
'set_time_zone' has been renamed to 'modify_time_zone'

The old names were confusing to me, so I thought they would be confusing to
users.

And finally after about 8 years (since version 6.4.0), the Windows binary is
back!

''',
'license' :
'''
Expand Down Expand Up @@ -6534,10 +6550,10 @@ def makeCommandExample( command, indent=0, slow=False ):
the epoch are undefined for this operator.
''',
'''
''' + makeCommandExample( '"1970-01-01 00:00:00" utc set_time_zone to_unix_time' ) + '''
''' + makeCommandExample( '"1970-01-01 00:00:00" utc modify_time_zone to_unix_time' ) + '''
''' + makeCommandExample( '2001-01-01 to_unix_time' ) + '''
''' + makeCommandExample( '2020-08-05 to_unix_time' ) + '''
''' + makeCommandExample( '"2038-01-18 22:14:07" utc set_time_zone to_unix_time' ),
''' + makeCommandExample( '"2038-01-18 22:14:07" utc modify_time_zone to_unix_time' ),
[ 'from_unix_time' ] ],

'uchar' : [
Expand Down Expand Up @@ -6700,7 +6716,7 @@ def makeCommandExample( command, indent=0, slow=False ):
''' + makeCommandExample( 'now' ) + '''
''' + makeCommandExample( 'now to_utc' ) + '''
''' + makeCommandExample( 'now to_utc to_local_time' ),
[ 'set_time_zone', 'to_utc' ] ],
[ 'modify_time_zone', 'to_utc' ] ],

'get_minute' : [
'date_time', 'returns the minute value of a date-time',
Expand Down Expand Up @@ -6782,7 +6798,7 @@ def makeCommandExample( command, indent=0, slow=False ):
''' + makeCommandExample( 'now' ),
[ 'today' ] ],

'set_time_zone' : [
'modify_time_zone' : [
'date_time', 'sets the date-time n to the timezone k',
'''
This operator sets the timezone value of n to timezone k. k can be the name of
Expand All @@ -6797,13 +6813,13 @@ def makeCommandExample( command, indent=0, slow=False ):
Here, we're taking a time and setting the time zone, meaning the actual time is
changed:

''' + makeCommandExample( 'now "Moscow, Russia" set_time_zone' ) + '''
''' + makeCommandExample( 'now "Moscow, Russia" set_time_zone to_local_time' ) + '''
''' + makeCommandExample( 'now "Moscow, Russia" modify_time_zone' ) + '''
''' + makeCommandExample( 'now "Moscow, Russia" modify_time_zone to_local_time' ) + '''
Here, we're converting to a different time zone, so the time remains the same:

''' + makeCommandExample( 'now "Moscow, Russia" to_time_zone' ) + '''
''' + makeCommandExample( 'now "Moscow, Russia" to_time_zone to_local_time' ),
[ 'to_time_zone', 'to_local_time' ] ],
[ 'convert_time_zone', 'to_local_time' ] ],

'today' : [
'date_time', 'returns the current date',
Expand All @@ -6829,27 +6845,27 @@ def makeCommandExample( command, indent=0, slow=False ):
''' + makeCommandExample( 'tomorrow' ),
[ 'yesterday', 'today' ] ],

'to_time_zone' : [
'convert_time_zone' : [
'date_time', 'converts the date-time n to the timezone k',
'''
This operator converts the date-time value of n to the timezone of k. k can be
the name of a timezone or the name of a geographic location.

To set the timezone for a particular date-time value without converting, use
'set_time_zone'.
'modify_time_zone'.
''',
'''
''' + makeCommandExample( 'now' ) + '''
Here, we're converting to a different time zone, so the time remains the same:

''' + makeCommandExample( 'now "Johannesburg, South Africa" to_time_zone' ) + '''
''' + makeCommandExample( 'now "Johannesburg, South Africa" to_time_zone to_local_time' ) + '''
''' + makeCommandExample( 'now "Johannesburg, South Africa" convert_time_zone' ) + '''
''' + makeCommandExample( 'now "Johannesburg, South Africa" convert_time_zone to_local_time' ) + '''
Here, we're taking a time and setting the time zone, meaning the actual time is
changed:

''' + makeCommandExample( 'now "Johannesburg, South Africa" set_time_zone' ) + '''
''' + makeCommandExample( 'now "Johannesburg, South Africa" set_time_zone to_local_time' ),
[ 'set_time_zone', 'to_local_time' ] ],
''' + makeCommandExample( 'now "Johannesburg, South Africa" modify_time_zone' ) + '''
''' + makeCommandExample( 'now "Johannesburg, South Africa" modify_time_zone to_local_time' ),
[ 'modify_time_zone', 'to_local_time' ] ],

'to_utc' : [
'date_time', 'returns the datetime converted to UTC time',
Expand All @@ -6858,7 +6874,7 @@ def makeCommandExample( command, indent=0, slow=False ):
''',
'''
''' + makeCommandExample( '"2020-08-29 13:13:18" to_utc' ),
[ 'to_local_time', 'set_time_zone' ] ],
[ 'to_local_time', 'modify_time_zone' ] ],

'yesterday' : [
'date_time', 'returns the previous date',
Expand Down
13 changes: 11 additions & 2 deletions rpn/rpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
from rpn.util.rpnDebug import debugPrint
from rpn.util.rpnGenerator import RPNGenerator

from rpn.time.rpnDateTime import formatDateTime

from rpn.rpnOperators import \
evaluateTerm, functionOperators, loadUserFunctionsFile, RPNFunction, saveUserFunctionsFile

from rpn.util.rpnOutput import \
formatDateTime, formatListOutput, formatOutput, formatUnits, printHelp, printHelpModeHelp, \
formatListOutput, formatOutput, formatUnits, printHelp, printHelpModeHelp, \
printInteractiveHelp, printTitleScreen

from rpn.util.rpnPersistence import \
Expand Down Expand Up @@ -384,6 +386,9 @@ def rpn( cmdArgs ):
# initialize globals
g.outputRadix = 10

# allow unlimited conversion lengths for integers
sys.set_int_max_str_digits(0)

# look for help argument before we start setting everything up (because it's faster this way)
showHelp = False
helpArgs = [ ]
Expand Down Expand Up @@ -434,8 +439,8 @@ def rpn( cmdArgs ):
parser.add_argument( '-g', '--integer_grouping', nargs='?', type=int, default=0,
const=g.defaultIntegerGrouping )
parser.add_argument( '-h', '--help', action='store_true' )

parser.add_argument( '-I', '--ignore_cache', action='store_true' )
parser.add_argument( '-k', '--show_timezones', action='store_true' )
parser.add_argument( '-l', '--line_length', type=int, default=g.defaultLineLength )
parser.add_argument( '-m', '--maximum_fixed', type=int, default=g.defaultMaximumFixed )
parser.add_argument( '-n', '--numerals', type=str, default=g.defaultNumerals )
Expand Down Expand Up @@ -542,6 +547,9 @@ def rpn( cmdArgs ):
g.ignoreCache = args.ignore_cache
g.refreshOEISCache = args.ignore_cache

if args.show_timezones:
g.showTimeZones = True

# handle -l
g.lineLength = args.line_length

Expand Down Expand Up @@ -679,6 +687,7 @@ def main( ):
helpFile = Path( getUserDataPath( ) + os.sep + 'help.pckl.bz2' )

if not helpFile.is_file( ):
debugPrint('Expected help file location: ', helpFile)
print( 'Please run "makeHelp" to initialize the help files.' )
sys.exit( 0 )

Expand Down
20 changes: 10 additions & 10 deletions rpn/rpnOperators.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
convertToUnixTimeOperator, getChristmasDayOperator, getDayOperator, getEpiphanyDayOperator, getHourOperator, \
getIndependenceDayOperator, getLocalTimeOperator, getMinuteOperator, getMonthOperator, getNewYearsDayOperator, \
getNowOperator, getSecondOperator, getTodayOperator, getTomorrowOperator, getUTCOperator, getVeteransDayOperator, \
getWeekdayOperator, getWeekdayNameOperator, getYearOperator, getYesterdayOperator, makeDateTimeOperator, \
makeJulianTimeOperator, RPNDateTime, setTimeZoneOperator
getDayOfWeekOperator, getDayOfWeekNameOperator, getYearOperator, getYesterdayOperator, makeDateTimeOperator, \
makeJulianTimeOperator, RPNDateTime, modifyTimeZoneOperator

from rpn.special.rpnDice import \
enumerateDiceOperator, enumerateMultipleDiceOperator, permuteDiceOperator, rollDiceOperator, \
Expand Down Expand Up @@ -2690,8 +2690,8 @@ def createSizedRangeOperator( a, b, c ):
'to_persian' : RPNOperator( getPersianCalendarDateOperator, 1 ),
'to_persian_name' : RPNOperator( getPersianCalendarDateNameOperator, 1 ),
'veterans_day' : RPNOperator( getVeteransDayOperator, 1 ),
'weekday' : RPNOperator( getWeekdayOperator, 1 ),
'weekday_name' : RPNOperator( getWeekdayNameOperator, 1 ),
'weekday' : RPNOperator( getDayOfWeekOperator, 1 ),
'weekday_name' : RPNOperator( getDayOfWeekNameOperator, 1 ),
'year_calendar' : RPNOperator( generateYearCalendarOperator, 1 ),

# chemistry
Expand Down Expand Up @@ -2770,19 +2770,19 @@ def createSizedRangeOperator( a, b, c ):
'ydhms' : RPNOperator( convertToYDHMSOperator, 1 ),

# date_time
'get_year' : RPNOperator( getYearOperator, 1 ),
'get_month' : RPNOperator( getMonthOperator, 1 ),
'convert_time_zone' : RPNOperator( convertTimeZoneOperator, 2 ),
'get_day' : RPNOperator( getDayOperator, 1 ),
'get_hour' : RPNOperator( getHourOperator, 1 ),
'get_minute' : RPNOperator( getMinuteOperator, 1 ),
'get_month' : RPNOperator( getMonthOperator, 1 ),
'get_second' : RPNOperator( getSecondOperator, 1 ),
'get_year' : RPNOperator( getYearOperator, 1 ),
'modify_time_zone' : RPNOperator( modifyTimeZoneOperator, 2 ),
'now' : RPNOperator( getNowOperator, 0 ),
'set_time_zone' : RPNOperator( setTimeZoneOperator, 2 ),
'today' : RPNOperator( getTodayOperator, 0 ),
'tomorrow' : RPNOperator( getTomorrowOperator, 0 ),
'to_local_time' : RPNOperator( getLocalTimeOperator, 1 ),
'to_time_zone' : RPNOperator( convertTimeZoneOperator, 2 ),
'to_utc' : RPNOperator( getUTCOperator, 1 ),
'today' : RPNOperator( getTodayOperator, 0 ),
'tomorrow' : RPNOperator( getTomorrowOperator, 0 ),
'yesterday' : RPNOperator( getYesterdayOperator, 0 ),

# figurate
Expand Down
6 changes: 3 additions & 3 deletions rpn/rpnVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#******************************************************************************

PROGRAM_NAME = 'rpnChilada'
PROGRAM_VERSION = '8.5.991'
PROGRAM_VERSION_NAME = '8.6.beta1'
COPYRIGHT_MESSAGE = 'copyright (c) 2022 (1988), Rick Gutleber ([email protected])'
PROGRAM_VERSION = '8.999.991'
PROGRAM_VERSION_NAME = '9.0.alpha1'
COPYRIGHT_MESSAGE = 'copyright (c) 2023 (1988), Rick Gutleber ([email protected])'

if PROGRAM_VERSION != PROGRAM_VERSION_NAME:
PROGRAM_VERSION_STRING = ' ' + PROGRAM_VERSION + ' (' + PROGRAM_VERSION_NAME + ')'
Expand Down
Loading

0 comments on commit 9c78c93

Please sign in to comment.