From 58619fe85ce5d7df50d12eff1ae3123e9175a47a Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Mon, 11 Jan 2016 04:24:06 +0100 Subject: [PATCH] Added float field and fix in datetime field --- paramecio/citoplasma/datetime.py | 10 ++++++++-- paramecio/cromosoma/corefields.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/paramecio/citoplasma/datetime.py b/paramecio/citoplasma/datetime.py index d2f0e61..aed14b4 100644 --- a/paramecio/citoplasma/datetime.py +++ b/paramecio/citoplasma/datetime.py @@ -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): diff --git a/paramecio/cromosoma/corefields.py b/paramecio/cromosoma/corefields.py index ac8b41a..204dbfd 100644 --- a/paramecio/cromosoma/corefields.py +++ b/paramecio/cromosoma/corefields.py @@ -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