当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeFormatInfo.SetAllDateTimePatterns方法代码示例

本文整理汇总了C#中System.Globalization.DateTimeFormatInfo.SetAllDateTimePatterns方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.SetAllDateTimePatterns方法的具体用法?C# DateTimeFormatInfo.SetAllDateTimePatterns怎么用?C# DateTimeFormatInfo.SetAllDateTimePatterns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.SetAllDateTimePatterns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DateTimeFromRubyString

 /// <summary>
 /// Converts a Ruby date string into a DateTime.
 /// </summary>
 /// <param name="date">The string to convert.</param>
 /// <returns>The converted data.</returns>
 public static DateTime DateTimeFromRubyString(string date)
 {
     DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();
     dateFormat.SetAllDateTimePatterns(new string[] { "yyyy-MM-dd HH:mm:ss zzz" }, 'Y');
     return DateTime.Parse(date, dateFormat);
 }
开发者ID:skopp,项目名称:vcap-dotnet,代码行数:11,代码来源:DEAUtilities.cs

示例2: client_ExecDetails

        void client_ExecDetails(object sender, ExecDetailsEventArgs e)
        {
            lock (_lockObject)
            {
                Symbol symbol = TWSAssetArgs.SymbolFromContract(e.Contract);

                string msg = "IB ExecDetails: " + e.Execution.Time + " " + e.Execution.Side + " " + symbol + " Order ID: " + e.Execution.OrderId +
                    " Size: " + e.Execution.Shares + " Price: " + e.Execution.Price;
                Trace.WriteLine(msg);
                //Console.WriteLine(msg);

                bool bIgnore = false;

                if (!string.IsNullOrEmpty(accountCode) && e.Execution.AccountNumber != accountCode)
                {
                    Trace.WriteLine("### Execution ignored - Wrong Account");
                    bIgnore = true;
                }
                else if (e.Execution.Shares < 0)
                {
                    Trace.WriteLine("### Execution Ignored - Negative Fill");
                    bIgnore = true;
                }

                if (!bIgnore)
                {

                    string datePattern = "yyyyMMdd hh:mm:ss";
                    DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();
                    dateFormat.SetAllDateTimePatterns(new[] { "yyyyMMdd" }, 'd');
                    dateFormat.SetAllDateTimePatterns(new[] { "HH:mm:ss" }, 't');

                    string[] dateSplit = e.Execution.Time.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    DateTime execDateTime = DateTime.ParseExact(dateSplit[0], "d", dateFormat).Date;
                    TimeSpan execTime = DateTime.ParseExact(dateSplit[1], "t", dateFormat).TimeOfDay;
                    execDateTime += execTime;

                    BrokerOrder openOrder;

                    if (openOrders.TryGetValue(e.OrderId.ToString(), out openOrder))
                    {
                        //	If we are reconnecting after a disconnect, we may get execDetails for partial fills that
                        //	we already know about.  So loop through the fills through this order and see if
                        //	we already know about this execution.
                        bool alreadyReported = false;
                        foreach (Fill fill in openOrder.Fills)
                        {
                            string fillTimeString = fill.FillDateTime.ToString(datePattern);
                            if (fillTimeString == e.Execution.Time && fill.Price.SymbolPrice == e.Execution.Price && fill.Quantity == e.Execution.Shares)
                            {
                                alreadyReported = true;
                            }
                        }

                        if (!alreadyReported)
                        {
                            string information = "";

                            Fill fill = new Fill();
                            fill.FillDateTime = execDateTime;
                            fill.Price = new Price(e.Execution.Price, e.Execution.Price);
                            fill.Quantity = e.Execution.Shares;

                            //	Apparently IB doesn't send commissions
                            fill.Commission = 0;

                            openOrder.Fills.Add(fill);

                            int totalFilled = 0;
                            foreach (Fill f in openOrder.Fills)
                            {
                                totalFilled += f.Quantity;
                            }
                            if (totalFilled < openOrder.Shares)
                            {
                                openOrder.OrderState = BrokerOrderState.PartiallyFilled;
                                information = "Partial fill";
                            }
                            else
                            {
                                openOrder.OrderState = BrokerOrderState.Filled;
                                openOrders.Remove(openOrder.OrderId);

                                //	Only remove from the potentially cancelled orders if it was completely filled
                                //	It may have been partially filled while disconnected and then cancelled
                                if (_gettingReconnectData)
                                {
                                    if (_potentiallyCancelledOrders.ContainsKey(openOrder.OrderId))
                                    {
                                        _potentiallyCancelledOrders.Remove(openOrder.OrderId);
                                    }
                                }
                            }

                            _filledOrders.RecordFill(openOrder.OrderId, fill.FillDateTime);

                            //var callback = OutOfBandCallback;
                            //if (callback != null)
                            //{
//.........这里部分代码省略.........
开发者ID:Tianjiao,项目名称:RightEdgePlugins,代码行数:101,代码来源:TWSPlugin.cs


注:本文中的System.Globalization.DateTimeFormatInfo.SetAllDateTimePatterns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。