Skip to main content

This Package Convert numeric date in the string to the datetime object

Project description

StringC

This Package inherits from str Class
Attributes:
Any string

Example:

from StringC import StringC
string = StringC("تاریخ برعکس ۱۳۹۹-۱۱-۳۰ تاریخ میلادی 1999/03/02 و تاریخ میلادی برعکس 05/12/95 حروف عربی مثل كيك ۱۳۹۹/۱۱/۳۰ تاریخ")
string.convert

Output:

"تاریخ برعکس 1399-11-30 تاریخ میلادی 1999/03/02 و تاریخ میلادی برعکس 05/12/95 حروف عربی مثل کیک 1399/11/30 تاریخ"

dates method

:param content: str
:return: list of datetime objects
At the beginning :
-Any Number in string will convert to En string Number
-Any Arabic Character in string will convert to Farsi
For now, it just finds dates in numeric formats which are separated with characters like "-" or "/" or "."
There is no difference if date is Jalali or Gregorian or Characters are Fa or Ar, this function convert date to
Gregorian datetime object

Example:

from StringC import StringC
string = "Today is 1400/01/18"
type(StringC.dates(string))
type(StringC.dates(string)[0])
StringC.dates(string)

Output:

<class 'list'>  
<class 'datetime.datetime'>  
[datetime.datetime(2021, 4, 7, 0, 0)] 

Example:

from StringC import StringC
string = "today is 2021/04/05"
StringC.dates(string)

Output:

[datetime.datetime(2021, 4, 5, 0, 0)]  

Example:

from StringC import StringC
string = "today is 2021/04/07 and Today is 1400/01/18 yesterday was 17/01/1400 yesterday also was 06/04/2021"
StringC.dates(string)

Output:

[  
datetime.datetime(2021, 4, 7, 0, 0),  
datetime.datetime(2021, 4, 7, 0, 0),  
datetime.datetime(2021, 4, 6, 0, 0),  
datetime.datetime(2021, 4, 6, 0, 0)  
]  

remove_extera_whitespace:

This Function operates on objects convert Property And replace more than one white space with one white space This Functions also remove any '\n' and any '\t' and instead place one white space :return: String Without any '\n' or '\t' Characters

Example:

string = '''
                از کلیه دارندگان واحدهای ممتاز، وکیل یا قائم مقام
                 قانونی صاحبان واحدهای ممتاز و همچنین نماینده و یا نمایندگان اشخاص حقوقی \t \t دعوت میگردد تا
                در جلسه ای که در ساعت12:00مورخ1400/02/27در   نبش بن بست \tمهران\n پلاک ۹۹برگزار می گردد حضور به هم رسانید
                    موضوع :  تصمیم گیری در خصوص تصویب تغییرات و هزینه های صندوق
                    سایر     موارد
                    '''
s = StringC(string)
print(s.remove_extra_whitespace())

Output:

از کلیه دارندگان واحدهای ممتاز، وکیل یا قائم مقام قانونی صاحبان واحدهای ممتاز و همچنین نماینده و یا نمایندگان اشخاص حقوقی دعوت میگردد تا در جلسه ای که در ساعت12:00مورخ1400/02/27در نبش بن بست مهران پلاک 99برگزار می گردد حضور به هم رسانید موضوع : تصمیم گیری در خصوص تصویب تغییرات و هزینه های صندوق سایر موارد

negative_number:

This Function operates on objects convert Property

:param start_with: str --> This string or Character shows how the negative number characters begin
:param end_with: str --> This string or character shows how he negative number characters end
:return: str

Example:

string = ' (7) جلسه ای که در ساعت12:00مورخ1400/02/27در  (۹۹) برگزار می گردد(12,000,000)زینه (0.356)  موارد'
s = StringC(string)
s.negative_number("(", ")")

Output:

As You can see in the results in this Example any number between '(' and ')' converted to Negative Number

-7 جلسه ای که در ساعت12:00مورخ1400/02/27در  -99 برگزار می گردد-12,000,000زینه -0.356  موارد

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

StringC-1.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

StringC-1.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file StringC-1.0.1.tar.gz.

File metadata

  • Download URL: StringC-1.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for StringC-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c1dbb67828641d1dbc50524c4dd501bbe9669cd562eff82b965fda513c8c46bd
MD5 1c7765a8901e4493b9d8d17ff6aaad2e
BLAKE2b-256 b4d1a065ad53bdbf0016101417555f9931390a82f3f5267219972d9bed3269f7

See more details on using hashes here.

File details

Details for the file StringC-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: StringC-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for StringC-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f2651f217962f8beb2f13beecc5333e2589661a5098ecbff0bed4c2fba7177d
MD5 8b835daf8c2e2101d5b23d5b59fafdaa
BLAKE2b-256 d6f44281919ea01ae14d6bc20d4d1e989e3f96d8a79ab8ccef3d720ee8716a0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page