Added float field and fix in datetime field

This commit is contained in:
Antonio de la Rosa 2016-01-11 04:24:06 +01:00
parent ae5d76432e
commit 58619fe85c
2 changed files with 36 additions and 2 deletions

View file

@ -131,11 +131,17 @@ def checkdatetime(y, m, d, h, mi, s):
# Obtain the actual time in gmt # Obtain the actual time in gmt
def now(): def now(gmt=False):
actual=datetime.today() 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): def obtain_timestamp(timeform):

View file

@ -30,6 +30,34 @@ class IntegerField(PhangoField):
return 'INT('+str(self.size)+') NOT NULL DEFAULT "0"' 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): class CharField(PhangoField):
pass pass