我希望计算特定日期之前的剩余天数,必须在同一视图表单中输入。
class saisir_soumission(osv.osv):
_name='saisir.soumission'
def compa_date(self,cr,uid,ids,args,fields,context=None):
r = {}
date_format = '%d-%m-%Y'
joining_date = 'Date_ouv_pli'
current_date = (datetime.today()).strftime(date_format)
d1 = datetime.strptime(joining_date, date_format).date()
d2 = datetime.strptime(current_date, date_format).date()
r = str((d2-d1).days + 1)
return r
_columns = {
'NumOffre' : fields.char('N° Offre'),
'organisme_s' : fields.char('Organisme'),
'caution' : fields.float('Caution'),
'Date_ouv_pli' : fields.date('Date Ouverture Plis'), #field to be entered
'observation_d' : fields.text('Observation'),
'compar' : fields.function(compa_date,string='Jours Restants'),
}
答案 0 :(得分:0)
您可以使用内置的日期时间timedelta object
>>> import datetime
>>> diff = d1 - datetime.date.today()
>>> diff.days
答案 1 :(得分:0)
下面我将发布一个通用解决方案供您参考
Specifications.java
希望这可以帮助你。
答案 2 :(得分:0)
这里是这个解决方案
var storageAccount = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
IRetryPolicy linearRetry = new LinearRetry(TimeSpan.FromSeconds(5), 10);
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("MyTable");
var tableRquestOptions = new TableRequestOptions()
{
RetryPolicy = linearRetry
};
table.CreateIfNotExists(tableRquestOptions);