Added float field and fix in datetime field
This commit is contained in:
parent
ae5d76432e
commit
58619fe85c
2 changed files with 36 additions and 2 deletions
|
|
@ -131,11 +131,17 @@ def checkdatetime(y, m, d, h, mi, s):
|
|||
|
||||
# Obtain the actual time in gmt
|
||||
|
||||
def now():
|
||||
def now(gmt=False):
|
||||
|
||||
actual=datetime.today()
|
||||
|
||||
return actual.strftime(sql_format_time)
|
||||
final_date=actual.strftime(sql_format_time)
|
||||
|
||||
if gmt:
|
||||
|
||||
final_date=local_to_gmt(final_date)
|
||||
|
||||
return final_date
|
||||
|
||||
def obtain_timestamp(timeform):
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,34 @@ class IntegerField(PhangoField):
|
|||
|
||||
return 'INT('+str(self.size)+') NOT NULL DEFAULT "0"'
|
||||
|
||||
class FloatField(PhangoField):
|
||||
|
||||
def __init__(self, name, size=11, required=False):
|
||||
super(FloatField, self).__init__(name, size, required)
|
||||
|
||||
def check(self, value):
|
||||
|
||||
self.error=False
|
||||
self.txt_error=''
|
||||
|
||||
try:
|
||||
|
||||
value=str(float(value))
|
||||
|
||||
if value=="0" and self.required==True:
|
||||
self.txt_error="The value is zero"
|
||||
self.error=True
|
||||
except:
|
||||
|
||||
value="0"
|
||||
self.error=True
|
||||
|
||||
return value
|
||||
|
||||
def get_type_sql(self):
|
||||
|
||||
return 'FLOAT NOT NULL DEFAULT "0"'
|
||||
|
||||
class CharField(PhangoField):
|
||||
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue