mhajiloo / persiantools Goto Github PK
View Code? Open in Web Editor NEWJalali date and datetime with other tools
License: MIT License
Jalali date and datetime with other tools
License: MIT License
persiantools/persiantools/utils.py
Line 7 in a88112b
I think the message should be better than this, since we don't have string type in python. something like
"string must be str, not {}".format(string.__class__.__name__)
It seems you don't need utils
at all.
You can use some kind of comprehension to make the code even much more readable and independent.
return ''.join(
dic.get(char, char) # maybe dic is not a good name though
for char in string
)
persiantools/persiantools/digits.py
Line 28 in a88112b
People usually use compile
object, when they want to use the sample pattern thousand of times, here you don't need it (maybe).
persiantools/persiantools/utils.py
Line 9 in a88112b
complete strftime for JalaliDate and add to JalaliDateTime
I think you can write a new function like convert_numbers
and accept from
and to
from the user. So? Then you don't need four functions that basically do the same thing.
def convert_numbers(from, to, string):
return output
How do I take the time interval between two dates based on the date ??
For example, the first date: 1400/02/26
Second Date: 1400/03/26
And I want to extract a list of days between these two dates
Hola! @mhajiloo has created a ZenHub account for the mhajiloo organization. ZenHub is the only project management tool integrated natively in GitHub – created specifically for fast-moving, software-driven teams.
To get set up with ZenHub, all you have to do is download the browser extension and log in with your GitHub account. Once you do, you’ll get access to ZenHub’s complete feature-set immediately.
ZenHub adds a series of enhancements directly inside the GitHub UI:
Still curious? See more ZenHub features or read user reviews. This issue was written by your friendly ZenHub bot, posted by request from @mhajiloo.
Hi @mhajiloo
Isn't it great if we add a function for separating each 3 digit with comma?!
Collecting persiantools
Downloading persiantools-1.2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-7vMtxF/persiantools/setup.py", line 14, in
long_description=readme(),
File "/tmp/pip-build-7vMtxF/persiantools/setup.py", line 7, in readme
with open('README.rst', encoding='utf8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7vMtxF/persiantools/
The replace
method in utils.py
starts with checking if the input is of type string
. This is not ideal because in python 2.x the strings are often of type unicode
and that renders some of the functionalities of persiantools unusbale.
For instance, this won't work in persiantools:
digits.fa_to_en(u'۱۲۳۴')
This can be address by allowing the unicode
data-type here
persiantools/persiantools/utils.py
Lines 14 to 32 in a88112b
isintance
takes a tuple of classes for the second argument. So you could basicly do something like this:
if not isinstance(value, (int, float)):
raise TypeError('value should int or float object')
return int(value)
assertRaises
persiantools/tests/test_utils.py
Line 16 in a88112b
When testing your module, the result in Sublime Text 3 and Python IDLE is the same and none of them show the Day name (for instance: Jomeh), but when using the Python or CMD directly to work with the same code, it works fine!
Test:
from persiantools.jdatetime import JalaliDate
from datetime import datetime
print(datetime.today()) # Output: 2018-08-24 12:33:20.700418
print(JalaliDate.today()) # Output: 1397-06-02
print(JalaliDate(1369, 7, 1)) # Output: 1369-07-01
persiantools/persiantools/utils.py
Line 19 in a88112b
value = int(value)
While jdatetime
defines MONTH_NAMES_FA and similar constants, they are not accessible directly through any methods. It would be great if we had a method that would accept the string 'خرداد'
and would return the number 3.
Ideally, similar methods should be also available to get the month number given the transliterated month names (for 'Khordad'
return 3), and for the days of the week.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.