3
3
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
4
4
# Copyright (c) 2018, Abdullah Alhazmy, Alhazmy13. All Rights Reserved.
5
5
# Copyright (c) 2020, Hamidreza Kalbasi. All Rights Reserved.
6
+ # Copyright (c) 2023, Nika Soltani Tehrani. All Rights Reserved.
6
7
7
8
# This library is free software; you can redistribute it and/or
8
9
# modify it under the terms of the GNU Lesser General Public
28
29
"دوازده" ,
29
30
"سیزده" ,
30
31
"چهارده" ,
31
- "پونزده " ,
32
- "شونزده " ,
33
- "هیفده " ,
34
- "هیجده " ,
32
+ "پانزده " ,
33
+ "شانزده " ,
34
+ "هفده " ,
35
+ "هجده " ,
35
36
"نوزده" ,
36
37
]
37
38
@@ -101,9 +102,9 @@ def float2tuple(self, value):
101
102
return pre , post , self .precision
102
103
103
104
def cardinal3 (self , number ):
104
- if ( number < 19 ) :
105
+ if number <= 19 :
105
106
return farsiOnes [number ]
106
- if ( number < 100 ) :
107
+ if number < 100 :
107
108
x , y = divmod (number , 10 )
108
109
if y == 0 :
109
110
return farsiTens [x ]
@@ -118,19 +119,19 @@ def cardinalPos(self, number):
118
119
res = ''
119
120
for b in farsiBig :
120
121
x , y = divmod (x , 1000 )
121
- if ( y == 0 ) :
122
+ if y == 0 :
122
123
continue
123
124
yx = self .cardinal3 (y ) + b
124
125
if b == ' هزار' and y == 1 :
125
126
yx = 'هزار'
126
- if ( res == '' ) :
127
+ if res == '' :
127
128
res = yx
128
129
else :
129
130
res = yx + farsiSeperator + res
130
131
return res
131
132
132
133
def fractional (self , number , level ):
133
- if ( number == 5 ) :
134
+ if number == 5 :
134
135
return "نیم"
135
136
x = self .cardinalPos (number )
136
137
ld3 , lm3 = divmod (level , 3 )
@@ -142,20 +143,21 @@ def to_currency(self, value):
142
143
143
144
def to_ordinal (self , number ):
144
145
r = self .to_cardinal (number )
145
- if ( r [- 1 ] == 'ه' and r [- 2 ] == 'س' ) :
146
+ if r [- 1 ] == 'ه' and r [- 2 ] == 'س' :
146
147
return r [:- 1 ] + 'وم'
147
148
return r + 'م'
148
149
149
150
def to_year (self , value ):
150
151
return self .to_cardinal (value )
151
152
152
- def to_ordinal_num (self , value ):
153
+ @staticmethod
154
+ def to_ordinal_num (value ):
153
155
return str (value )+ "م"
154
156
155
157
def to_cardinal (self , number ):
156
158
if number < 0 :
157
159
return "منفی " + self .to_cardinal (- number )
158
- if ( number == 0 ) :
160
+ if number == 0 :
159
161
return "صفر"
160
162
x , y , level = self .float2tuple (number )
161
163
if y == 0 :
0 commit comments