这里我给定了json数据格式
var data = [Mon Jul 16 2018 21:54:14 GMT+0530 (India Standard Time), Mon Jul 16 2018 21:54:14 GMT+0530 (India Standard Time)]
以及如何将其转换为
classname(20180716,20180716)
我尝试使用split方法将数据转换为数组,但是我没有任何建议
我也遵循联接和拆分方法
function convert(str) {
var date = new Date(str),
mnth = ("0" + (date.getMonth()+1)).slice(-2),
day = ("0" + date.getDate()).slice(-2);
return [ date.getFullYear(), mnth, day ].join("-");
}
convert("Thu Jun 09 2018 00:00:00 GMT+0530 (India Standard Time)");
答案 0 :(得分:0)
按如下所示使用$refs
:
/// <summary>
/// Use this extension method to update an observable collection without recreating it. This method keeps also track of the order items of the new collection.
/// </summary>
/// <remarks>This method was intended for short collection. The base complexity is around O(n+m) but the use of the IndexOf method make the complexity O(n*m)...O((n+m)*m).</remarks>
/// <typeparam name="T"></typeparam>
/// <param name="collection">The collection to update.</param>
/// <param name="newCollection">The source of the new items.</param>
public static void UpdateCollection<T>(this ObservableCollection<T> collection, IList<T> newCollection)
{
if ((null == newCollection) || (newCollection.Count == 0))
{
collection.Clear();
return;
}
var i = 0;
foreach (var it in newCollection)
{
if (collection.Count > i)
{
var itemIndex = collection.IndexOf(it);
// This method would be match better, but it does not exist ;)
//var remaining = list.Count - i;
//itemIndex = list.IndexOf(it, i, remaining);
if (itemIndex < 0)
{
// this item was not found in the list
collection.Insert(i, it);
}
else if (itemIndex > i)
{
// item is in the list but on a different place
collection.Move(itemIndex, i);
}
else
{
// here the 'itemIndex' is less than or equal to 'i' --> we may have duplicate item
// we check if the current items are the same!?
if (!EqualityComparer<T>.Default.Equals(collection[i], it))
{
// the items are different! The question is: do we need this item later?
// --> maybe: we keep (higher complexity)
collection.Insert(i, it);
// --> not: we can replace (lower complexity)
// list[i] = it;
}
else
{
// yop: the items are the same, we do nothing.
}
}
}
else
{
// add new item
collection.Add(it);
}
i++;
}
// we remove the remaining items.
while (collection.Count > newCollection.Count) {
collection.RemoveAt(i);
};
}
使用分号分隔行对我有用:
<input type="button" value="Sign On" class="ButtonSm" onclick="submitForm();">
关键是分别声明Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate "www.xxx.com"
Do While (IE.Busy)
Application.Wait DateAdd("s", 1, Now)
Loop
With IE.Document
.getElementByID("USER").Value = UserName
.getElementByID("PASSWORD").Value = Password
.getElementByClassName("ButtonSm").Click
End With
End Sub
。
输出:
data
要处理所有日期的数组:
var data = [
"Mon Jul 16 2018 21:54:14 GMT+0530 (India Standard Time)",
"Mon Jul 16 2018 21:54:14 GMT+0530 (India Standard Time)"
];
还请注意,function convert(str) {
var date = new Date(str);
var mnth = ("0" + (date.getMonth() + 1)).slice(-2);
var day = ("0" + date.getDate()).slice(-2);
return [date.getFullYear(), mnth, day].join("-");
}
console.log(convert("Thu Jun 09 2018 00:00:00 GMT+0530 (India Standard Time)"));
应该包含字符串数组。