2017-02-10 60 views
0

我們目前有一個按「週數」從「登記日期」到「今天」計算的計數器。在某些事件發生後停止跑道計算

我們希望每隔一個單獨的字段(「已發送優惠」)更新後,我們將不再計算週數。

這可能嗎?

回答

0

有幾種處理方法。這是一個例子。所以,Podio應用程序有兩個字段,Date設置日期和時間,Category有多個選項來顯示如何處理日期和時間。

var category = @Category; 
var now = new Date; 
var today = new Date; 
today.setHours(0, 0, 0, 0); 
var durationTillNow = (now - @Date)/1000/60/60/24; 
var fromDate = @Date; 
fromDate.setHours(0, 0, 0, 0); 
var durationTillNowWithoutTime = (today - fromDate)/1000/60/60/24; 

if (category == 'round to nearest number') { 
    "Rounded to: " + Math.round(durationTillNow).toString() + " day(s)"; 
} else if (category == 'round up') { 
    "Round up: " + Math.ceil(durationTillNow).toString() + " day(s)"; 
} else if (category == 'round down') { 
    "Round down: " + Math.floor(durationTillNow).toString() + " day(s)"; 
} else if (category == 'show full diff') { 
    "Full diff: " + durationTillNow.toString() + " day(s)"; 
} else if (category == 'just ignore time') { 
    "Ignoring time part: " + durationTillNowWithoutTime.toString() + " day(s)"; 

} else if (category == 'something else') { 
"it's something else selected"; 
} else { 
    "yet another else option selected"; 
} 
相關問題