Difference betwen dates is wrong - flutter

The result of this
nextEventDuration = nextRace.raceTime.difference(nowTime);
print(nextRace.raceTime.toIso8601String() + " " + nowTime.toIso8601String() + " " + nextEventDuration.inHours.toString());
is
2021-03-28T17:00:00.000 2021-03-27T17:00:00.000 23
It should be 24 right?

I don't think it's 24 hours, it should be 23:59:59:999.
What is the result of nextEventDuration.toString() in seconds?

Related

'range' cannot be used as a variable or function name

the error is:
Compilation error. Line 13: 'range' cannot be used as a variable or
function name.
//#version=5
indicator('My Script')
// 计算振幅
range = high - low
// 定义信息框显示的内容
info = "开盘价: " + tostring(open) + "\n"
+ "最高价: " + tostring(high) + "\n"
+ "最低价: " + tostring(low) + "\n"
+ "振幅: " + tostring(range) + "\n"
+ "成交量: " + tostring(volume)
// 定义当鼠标悬停在当前k线时显示信息框
bgcolor(not nz(bgcolor[1]) and barstate.ishovered, color.new(color.red, 50))
// 当鼠标悬停在当前k线时,显示信息框
label.new(bar_index, high, text=info, xloc=xloc.bar_time, yloc=yloc.abovebar
Your code is full of error.
For the range problem, just change :
range = high - low
To :
myrange = high - low

Project taking too long to build and run after adding complex query

I have integrated SQLite.swift framework in one of my swift project and everything was working fine until i added the below query. After adding the below query project is taking too long to build. I waited for 30 mins but still project is n't complied.
do
{
let stmt = try DB!.prepare ("SELECT e." + ENDPOINT_ID + " as _id, lk." + HUB_ID + ", e." + X_ENDPOINT_ID + ", e." + ENDPOINT_DESC + ", e." + ENDPOINT_TYPE_ID +", et." + ENDPOINT_STATUS_MIN + ", et." + ENDPOINT_STATUS_MAX + ", e." + ENDPOINT_STATUS + " FROM " + TABLE_ENDPOINT + " as e INNER JOIN " + TABLE_ENDPOINT_TYPE + " as et " +
" ON e." + ENDPOINT_TYPE_ID + " = et." + ENDPOINT_TYPE_ID +
" INNER JOIN " + TABLE_LINKING + " as lk " +
" ON e." + ENDPOINT_ID + " = lk." + ENDPOINT_ID +
" INNER JOIN " + TABLE_NODE + " as n " +
" ON lk." + NODE_ID + " = n." + NODE_ID +
" INNER JOIN " + TABLE_NODE_TYPE + " as nt " +
" ON n." + NODE_TYPE_ID + " = nt." + NODE_TYPE_ID +
" WHERE lk." + SECTION_ID + "=" + section_Id +
" AND nt." + NODE_CATEGORY + " = "S" " +
" ORDER BY e." + ENDPOINT_ID + " ASC")
let arr = Array(try stmt.run)
print("\(arr)")
return arr
} catch {
print("failed: \(error)")
return []
}
If i comment the above code and try to run the project it takes hardly a minute to run the project but after adding this code, it's taking hell lot of time. I have waited for almost 30 mins but still the project is not compiled nor it's throwing any error.
Thanks in advance for help
The Swift compiler has difficulties to deal with big string literals. See also this question for further hints.
I would recommend to split up the sql and to build a string variable in small steps:
var sql = "SELECT e." + ENDPOINT_ID
sql = sql + HUB_ID + ", e."
sql = sql + X_ENDPOINT_ID + ", e."
...
let stmt = try DB!.prepare(sql)
let query = (TABLE_ENDPOINT.select(TABLE_ENDPOINT[ENDPOINT_ID], TABLE_LINKING[HUB_ID], TABLE_ENDPOINT[ETCT_ENDPOINT_ID], TABLE_ENDPOINT[ENDPOINT_DESC], TABLE_ENDPOINT[ENDPOINT_TYPE_ID], TABLE_ENDPOINT_TYPE[ENDPOINT_STATUS_MIN], TABLE_ENDPOINT_TYPE[ENDPOINT_STATUS_MAX], TABLE_ENDPOINT[ENDPOINT_STATUS]).join(TABLE_ENDPOINT_TYPE, on: TABLE_ENDPOINT[ENDPOINT_TYPE_ID] == TABLE_ENDPOINT_TYPE[ENDPOINT_TYPE_ID]).join(TABLE_LINKING, on: TABLE_ENDPOINT[ENDPOINT_ID] == TABLE_LINKING[ENDPOINT_ID]).join(TABLE_NODE, on: TABLE_LINKING[NODE_ID] == TABLE_NODE[NODE_ID]).join(TABLE_NODE_TYPE, on: TABLE_NODE[NODE_TYPE_ID] == TABLE_NODE_TYPE[NODE_TYPE_ID])
.filter(TABLE_LINKING[SECTION_ID] == section_Id && TABLE_NODE_TYPE[NODE_CATEGORY] == "S")
.order(TABLE_ENDPOINT[ENDPOINT_ID].asc))
let arr = Array(try DB!.prepare(query))

Get previous day in an Expression

Just need help on this as I am new at SSIS. I got an expression but I want yesterday, not today.
"Daily "+ (RIGHT("0" + (DT_STR,4,1252) DatePart("yyyy",getdate()),4))+(RIGHT("0" + (DT_STR,4,1252) DatePart("mm",getdate()),2))+(RIGHT("0" + (DT_STR,4,1252) DatePart("dd",getdate()),2))+".CSV"
Currently it looks like this
Daily 20161006.CSV
What I want is
Daily 20161005.CSV
Here you go.
"Daily "
+ (DT_WSTR, 4) YEAR(DATEADD("day",-1,GETDATE()))
+ RIGHT("0" + (DT_WSTR, 2) DATEPART("MM", DATEADD("day", -1, GETDATE())),2)
+ RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", DATEADD("day", -1, GETDATE())),2)
+ ".CSV"
It looks like you are in Australia, so it is 20161006 there, but in US Right now, it is 20161005, and see how it shows yesterday i.e. 20161004 in the file name when I clicked Evaluate value
"Daily "+ (RIGHT("0" + (DT_STR,4,1252) DatePart("yyyy",getdate()),4))+(RIGHT("0" + (DT_STR,4,1252) DatePart("mm",getdate()),2))+(RIGHT("0" +(DT_STR,4,1252) (DatePart("dd",getdate())-1),2))+".CSV"
This should work.

jQuery UI DatePicker date convert to RFC 3339 format

Currently working on the Google Calendar API and basically my end will provide Start and End date for user to pick the date and time. But would like anyone to advise how to convert them from (DatePicker/TimePicker/input field) to RFC 3339 format (e.g. 2013-07-24T10:00:00.000-07:00).
var date = new Date();
var timeZone = date.getTimezoneOffset();
alert(date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + "T" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "." + date.getMilliseconds() + (timeZone > 0 ? "-" : "+") + Math.floor(Math.abs(timeZone) / 60) + ":" + Math.abs(timeZone) % 60);

Checking User Agent in Wicket

I am using wicket 1.5 and I am not able to see in the getClientInfo() method
(WebRequest)RequestCycle.get().getRequest()
I saw the other place this code
WebClientInfo clientInfo = (WebClientInfo)WebRequestCycle.get().getClientInfo();
But I am not able to see any WebRequestCycle in Wicket 1.5.
Any ideas how to check the user agent in Wicket 1.5?
The easiest way is to use
WebSession.get().getClientInfo().getUserAgent();
On newer Wicket Versions (6 or newer), you should use:
WebClientInfo clientInfo = new WebClientInfo(getRequestCycle());
System.out.println("Client: " + clientInfo.getUserAgent());
System.out.println("Navigator: " + clientInfo.getProperties().getNavigatorAppName() + ", version " + clientInfo.getProperties().getNavigatorAppVersion() + ", codName: " + clientInfo.getProperties().getNavigatorAppCodeName() + ", plataform: " + clientInfo.getProperties().getNavigatorPlatform() + ", AppCodName: " + clientInfo.getProperties().getNavigatorAppCodeName());
System.out.println("NavigatorUserAgent: " + clientInfo.getProperties().getNavigatorUserAgent());
System.out.println("Tamanho da tela (Width x Height): " + clientInfo.getProperties().getScreenWidth() + " x " + clientInfo.getProperties().getScreenHeight() );
You can also do:
((WebRequest) getRequest()).getHeader("User-Agent")