Fixes in dates
This commit is contained in:
parent
833e3219ea
commit
4d82ddced0
3 changed files with 56 additions and 25 deletions
|
|
@ -77,6 +77,7 @@ class DateTimeField(PhangoField):
|
|||
def show_formatted(self, value):
|
||||
|
||||
# Convert to paramecio value
|
||||
|
||||
value=str(value)
|
||||
value=value.replace('-', '').replace(':', '').replace(' ', '')
|
||||
|
||||
|
|
|
|||
|
|
@ -35,23 +35,36 @@ class DateForm(BaseForm):
|
|||
|
||||
def form(self):
|
||||
|
||||
y=''
|
||||
m=''
|
||||
d=''
|
||||
h=''
|
||||
min=''
|
||||
s=''
|
||||
min_time=''
|
||||
if type(self.default_value).__name__!='datetime':
|
||||
|
||||
time=format_timedata(self.default_value)
|
||||
y=''
|
||||
m=''
|
||||
d=''
|
||||
h=''
|
||||
min=''
|
||||
s=''
|
||||
min_time=''
|
||||
|
||||
time=format_timedata(self.default_value)
|
||||
|
||||
if time[0]:
|
||||
y=int(time[0])
|
||||
m=int(time[1])
|
||||
d=int(time[2])
|
||||
h=int(time[3])
|
||||
min_time=int(time[4])
|
||||
s='00' #int(time[5])
|
||||
|
||||
if time[0]:
|
||||
y=int(time[0])
|
||||
m=int(time[1])
|
||||
d=int(time[2])
|
||||
h=int(time[3])
|
||||
min_time=int(time[4])
|
||||
s=int(time[5])
|
||||
else:
|
||||
|
||||
y=self.default_value.year #"{:>10}".format(s)
|
||||
m="{:02d}".format(self.default_value.month)
|
||||
d="{:02d}".format(self.default_value.day)
|
||||
h="{:02d}".format(self.default_value.hour)
|
||||
min_time="{:02d}".format(self.default_value.minute)
|
||||
s='00'
|
||||
|
||||
pass
|
||||
|
||||
return self.t.load_template('forms/dateform.phtml', yes_time=self.yes_time, form=self.name, y=y, m=m, d=d, h=h, min=min_time, s=s)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,38 +1,55 @@
|
|||
${add_js('jquery.min.js', 'admin')}
|
||||
|
||||
<input type="number" min="1" max="31" name="${form}_day" id="time_${form}_day" class="form_day" value="${d}" size="2" maxlength="2"/>
|
||||
<!--<input type="number" min="1" max="31" name="${form}_day" id="time_${form}_day" class="form_day" value="${d}" size="2" maxlength="2"/>
|
||||
<input type="number" min="1" max="12" name="${form}_month" id="time_${form}_month" class="form_month" value="${m}" size="2" maxlength="2"/>
|
||||
<input type="number" name="${form}_year" id="time_${form}_year" class="form_year" value="${y}" size="4" maxlength="4"/>
|
||||
<input type="number" name="${form}_year" id="time_${form}_year" class="form_year" value="${y}" size="4" maxlength="4"/>-->
|
||||
<%
|
||||
|
||||
date=''
|
||||
|
||||
if d!='':
|
||||
date='-'.join((str(y), str(m), str(d)))
|
||||
|
||||
time=''
|
||||
|
||||
if h!='':
|
||||
time=':'.join((str(h), str(min)))
|
||||
|
||||
%>
|
||||
${date}
|
||||
<input type="date" value="${date}" name="${form}_date" id="${form}_date" />
|
||||
% if yes_time==True:
|
||||
<input type="number" min="0" max="23" name="${form}_hour" id="time_${form}_hour" class="form_hour" value="${h}" size="2" maxlength="2"/>
|
||||
<!--<input type="number" min="0" max="23" name="${form}_hour" id="time_${form}_hour" class="form_hour" value="${h}" size="2" maxlength="2"/>
|
||||
<input type="number" min="0" max="60" name="${form}_minute" id="time_${form}_minute" class="form_minute" value="${min}" size="2" maxlength="2"/>
|
||||
<input type="number" min="0" max="60" name="${form}_second" id="time_${form}_second" class="form_second" value="${s}" size="2" maxlength="2"/>
|
||||
<input type="number" min="0" max="60" name="${form}_second" id="time_${form}_second" class="form_second" value="${s}" size="2" maxlength="2"/>-->
|
||||
<input type="time" value="${time}" name="${form}_time" id="${form}_time" />
|
||||
% endif
|
||||
<input type="hidden" name="${form}" id="time_${form}" value="" />
|
||||
|
||||
<script language="javascript">
|
||||
$(document).submit(function () {
|
||||
|
||||
year=$("#time_${form}_year").val().toString();
|
||||
/*year=$("#time_${form}_year").val().toString();
|
||||
month=$("#time_${form}_month").val().toString();
|
||||
day=$("#time_${form}_day").val().toString();
|
||||
|
||||
year=add_extra_length(year, 4);
|
||||
month=add_extra_length(month, 2);
|
||||
day=add_extra_length(day, 2);
|
||||
day=add_extra_length(day, 2); */
|
||||
|
||||
final_time=year+month+day
|
||||
//final_time=year+month+day
|
||||
final_time=$('#${form}_date').val().replace(/-/g, '');
|
||||
|
||||
% if yes_time==True:
|
||||
hour=$("#time_${form}_hour").val().toString();
|
||||
/*hour=$("#time_${form}_hour").val().toString();
|
||||
minute=$("#time_${form}_minute").val().toString();
|
||||
second=$("#time_${form}_second").val().toString();
|
||||
|
||||
hour=add_extra_length(hour, 2);
|
||||
minute=add_extra_length(minute, 2);
|
||||
second=add_extra_length(second, 2);
|
||||
second=add_extra_length(second, 2); */
|
||||
|
||||
final_time+=final_time;
|
||||
final_time+=$('#${form}_time').val().replace(':', '')+'00';
|
||||
|
||||
% else:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue