Fixes in dates

This commit is contained in:
Antonio de la Rosa 2025-07-05 02:08:19 +02:00
parent 833e3219ea
commit 4d82ddced0
3 changed files with 56 additions and 25 deletions

View file

@ -77,6 +77,7 @@ class DateTimeField(PhangoField):
def show_formatted(self, value): def show_formatted(self, value):
# Convert to paramecio value # Convert to paramecio value
value=str(value) value=str(value)
value=value.replace('-', '').replace(':', '').replace(' ', '') value=value.replace('-', '').replace(':', '').replace(' ', '')

View file

@ -35,6 +35,8 @@ class DateForm(BaseForm):
def form(self): def form(self):
if type(self.default_value).__name__!='datetime':
y='' y=''
m='' m=''
d='' d=''
@ -51,7 +53,18 @@ class DateForm(BaseForm):
d=int(time[2]) d=int(time[2])
h=int(time[3]) h=int(time[3])
min_time=int(time[4]) min_time=int(time[4])
s=int(time[5]) s='00' #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) 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)

View file

@ -1,38 +1,55 @@
${add_js('jquery.min.js', 'admin')} ${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" 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: % 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}_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 % endif
<input type="hidden" name="${form}" id="time_${form}" value="" /> <input type="hidden" name="${form}" id="time_${form}" value="" />
<script language="javascript"> <script language="javascript">
$(document).submit(function () { $(document).submit(function () {
year=$("#time_${form}_year").val().toString(); /*year=$("#time_${form}_year").val().toString();
month=$("#time_${form}_month").val().toString(); month=$("#time_${form}_month").val().toString();
day=$("#time_${form}_day").val().toString(); day=$("#time_${form}_day").val().toString();
year=add_extra_length(year, 4); year=add_extra_length(year, 4);
month=add_extra_length(month, 2); 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: % if yes_time==True:
hour=$("#time_${form}_hour").val().toString(); /*hour=$("#time_${form}_hour").val().toString();
minute=$("#time_${form}_minute").val().toString(); minute=$("#time_${form}_minute").val().toString();
second=$("#time_${form}_second").val().toString(); second=$("#time_${form}_second").val().toString();
hour=add_extra_length(hour, 2); hour=add_extra_length(hour, 2);
minute=add_extra_length(minute, 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: % else: