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


C# DateTime.Select方法代码示例

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


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

示例1: DateTimeTest

        public void DateTimeTest(DateTime[] value)
        {
            // VB6 has a 1 ms resolution
            if (value != null)
                value = value.Select(dt => dt.RoundToMillisecond()).ToArray();

            Utils.CheckSerializeDeserialize(value);
        }
开发者ID:FrancescoDeVittori,项目名称:DMC12-serializer,代码行数:8,代码来源:SimpleArraysTest.cs

示例2: Main

        static void Main(string[] args)
        {
            var dates = new DateTime[3]{new DateTime(2016,12,1), new DateTime(2017, 4, 13), new DateTime(2019,8,21)};
            var values = new double[3] { 1, 4, 6 };

            // A) interpolate using Datetime.Ticks()
            // b) using DateTime.ToOADate (removes millisconds) -- @@

            var valD = dates.Select(t => t.ToOADate());

            var interpol = Interpolate.Linear(valD, values);

            Console.WriteLine(interpol.Interpolate(new DateTime(2017, 3, 31).ToOADate()));
            Console.ReadLine();

                    

        }
开发者ID:BertiFuchsi,项目名称:GanovenFutter,代码行数:18,代码来源:Program.cs

示例3: DropFilesetsFromTable

		/// <summary>
		/// Drops all entries related to operations listed in the table.
		/// </summary>
		/// <param name="toDelete">The fileset entries to delete</param>
		/// <param name="transaction">The transaction to execute the commands in</param>
		/// <returns>A list of filesets to delete</returns>
		public IEnumerable<KeyValuePair<string, long>> DropFilesetsFromTable(DateTime[] toDelete, System.Data.IDbTransaction transaction)
		{
			using(var cmd = m_connection.CreateCommand())
			{
				cmd.Transaction = transaction;

				var q = "";
				foreach(var n in toDelete)
					if (q.Length == 0)
						q = "?";
					else
						q += ",?";
						
				//First we remove unwanted entries
				cmd.ExecuteNonQuery(@"DELETE FROM ""FilesetEntry"" WHERE ""FilesetID"" IN (SELECT ""ID"" FROM ""Fileset"" WHERE ""Timestamp"" IN (" + q + @")) ", toDelete.Select(x => NormalizeDateTimeToEpochSeconds(x)).Cast<object>().ToArray());
				var deleted = cmd.ExecuteNonQuery(@"DELETE FROM ""Fileset"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""FilesetID"" FROM ""FilesetEntry"") ");
	
				if (deleted != toDelete.Length)
					throw new Exception(string.Format("Unexpected number of deleted filesets {0} vs {1}", deleted, toDelete.Length));
	
				//Then we delete anything that is no longer being referenced
				cmd.ExecuteNonQuery(@"DELETE FROM ""File"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""FileID"" FROM ""FilesetEntry"") ");
				cmd.ExecuteNonQuery(@"DELETE FROM ""Metadataset"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""MetadataID"" FROM ""File"") ");
				cmd.ExecuteNonQuery(@"DELETE FROM ""Blockset"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""BlocksetID"" FROM ""File"" UNION SELECT DISTINCT ""BlocksetID"" FROM ""Metadataset"") ");
				cmd.ExecuteNonQuery(@"DELETE FROM ""BlocksetEntry"" WHERE ""BlocksetID"" NOT IN (SELECT DISTINCT ""ID"" FROM ""Blockset"") ");
				cmd.ExecuteNonQuery(@"DELETE FROM ""BlocklistHash"" WHERE ""BlocksetID"" NOT IN (SELECT DISTINCT ""ID"" FROM ""Blockset"") ");
				
				//We save the block info for the remote files, before we delete it
				cmd.ExecuteNonQuery(@"INSERT INTO ""DeletedBlock"" (""Hash"", ""Size"", ""VolumeID"") SELECT ""Hash"", ""Size"", ""VolumeID"" FROM ""Block"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""BlockID"" AS ""BlockID"" FROM ""BlocksetEntry"" UNION SELECT DISTINCT ""ID"" FROM ""Block"", ""BlocklistHash"" WHERE ""Block"".""Hash"" = ""BlocklistHash"".""Hash"") ");
				cmd.ExecuteNonQuery(@"DELETE FROM ""Block"" WHERE ""ID"" NOT IN (SELECT DISTINCT ""BlockID"" FROM ""BlocksetEntry"" UNION SELECT DISTINCT ""ID"" FROM ""Block"", ""BlocklistHash"" WHERE ""Block"".""Hash"" = ""BlocklistHash"".""Hash"") ");		
	
				//Find all remote filesets that are no longer required, and mark them as delete
				var updated = cmd.ExecuteNonQuery(@"UPDATE ""RemoteVolume"" SET ""State"" = ? WHERE ""Type"" = ? AND ""State"" IN (?, ?) AND ""ID"" NOT IN (SELECT ""VolumeID"" FROM ""Fileset"") ", RemoteVolumeState.Deleting.ToString(), RemoteVolumeType.Files.ToString(), RemoteVolumeState.Uploaded.ToString(), RemoteVolumeState.Verified.ToString());
	
				if (deleted != updated)
					throw new Exception(string.Format("Unexpected number of remote volumes marked as deleted. Found {0} filesets, but {1} volumes", deleted, updated));
	
				using (var rd = cmd.ExecuteReader(@"SELECT ""Name"", ""Size"" FROM ""RemoteVolume"" WHERE ""Type"" = ? AND ""State"" = ? ", RemoteVolumeType.Files.ToString(), RemoteVolumeState.Deleting.ToString()))
				while (rd.Read())
					yield return new KeyValuePair<string, long>(rd.GetValue(0).ToString(), Convert.ToInt64(rd.GetValue(1)));
			}
		}
开发者ID:admz,项目名称:duplicati,代码行数:48,代码来源:LocalDeleteDatabase.cs

示例4: EventFilterBuilder

 private DateTime[] EventFilterBuilder(DateTime[] eventDates, RetrieveEventDataDelegate retrieveDataForEvents)
 {
     // post filter events
     // with the above event dates from preselection, we filter out the ones match in post filter condition
     var eventBuilder = Singleton<EventFilterBuilder>.Instance;
     eventBuilder.eventDates = eventDates.Select(e => e.Date).ToArray();   // we only need the date without time when using it for filter event.
     var filteredEventDates = eventBuilder.GenerateFilteredDates(GiveMeEventSelectorVM().BuildEventsPostFilterGroup(retrieveDataForEvents));
     return filteredEventDates;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:9,代码来源:DailyDataAroundEventControl.cs

示例5: SetFirstDayMonthCodeAndRollDates

        private Tuple<MonthCodeYear, int> SetFirstDayMonthCodeAndRollDates(DateTime[] rollDates, DateTime firstDate)
        {
            var closestRollDate = rollDates.Select(d => new{date=d, diff=(d - firstDate).TotalDays})
                                            .OrderBy(s => s.diff)
                                            .Where(result => result.diff > 0)
                                            .Select(a => a.date).FirstOrDefault();

            var closestRollDateIndex = Array.IndexOf(rollDates, closestRollDate);

            // the below logic may need to be reviewed. How do we compute exactly what the current contract is without market information
            // different market has different rolldates. the below way has the assumption that works for US and German market

            // if the date is in the same month as upcoming roll date, we wait unti the roll date so we use the last contract
            // eg. if roll date is 8 Mar, and we are on 1 Mar, we still use Mar contract and use Jun contract after 8 Mar.            
            var contractMonthCode = FutureBondLookup.GetQuarterlyContractMonth(firstDate);
            if (firstDate < closestRollDate && firstDate.Month == closestRollDate.Month)
            {
                // use the prev contract
                contractMonthCode = contractMonthCode.GetMonthOffset(-3);
            }

            return new Tuple<MonthCodeYear, int>(contractMonthCode, closestRollDateIndex);
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:23,代码来源:FirstIssueFutureRollLogic.cs

示例6: AddScatterSeries

        private ChartLayerAppearance AddScatterSeries(DateTime[] dates_, double[] values_, string desc_, Color color_,
            int yAxisExtent_, string yLabelFormat_, object nanREplaceValue_ = null,
            NullHandling nullHandling_ = NullHandling.Zero, string[] pointLabels_ = null,
            SymbolIcon icon = SymbolIcon.Circle)
        {
            if (lineChartDataDisplay1.DataTableKeys.Contains(desc_))
                desc_ = desc_ + "(2)";

            if(ViewModel.HasTechnicals)
                return lineChartDataDisplay1.AddScatterSeries(dates_.Select(d => d.ToString("dd MMM yy")).ToArray(), values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);
            else
                return lineChartDataDisplay1.AddScatterSeries(dates_, values_, desc_, color_, yAxisExtent_, yLabelFormat_, nanREplaceValue_, nullHandling_, icon: icon);

        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:14,代码来源:HistSeriesChartView.cs

示例7: TestTSourceWithSelector

        public void TestTSourceWithSelector()
        {
            // NonNullable -> Nullable
            IEnumerable<DateTime> dateTimes = new DateTime[]{
                new DateTime (2014, 3, 21),
                new DateTime (2014, 6, 21),
                new DateTime (2014, 9, 23),
                new DateTime (2014, 12, 22),
            };
            Assert.That (dateTimes.Min (it => it.ToString ()), Is.EqualTo ("03/21/2014 00:00:00"));

            // NonNullable -> NonNullable
            IEnumerable<long> dateTimeTics = dateTimes.Select (it => it.Ticks);
            Assert.That (dateTimeTics.Min (it => new DateTime (it)), Is.EqualTo (new DateTime(2014, 3, 21)));

            IEnumerable<string> strings = new string[] {
                "Cube",
                "Sphere",
                "Capsule",
                "Cylinder",
                "Plane",
                "Quad"
            };
            // Nullable -> NonNullable
            Assert.That (strings.Min (it => it.Length), Is.EqualTo (4));
            // Nullable -> Nullable
            Assert.That (strings.Min (it => it.ToUpper ()), Is.EqualTo ("CAPSULE"));
        }
开发者ID:ELN,项目名称:UniLinq,代码行数:28,代码来源:MinTest.cs

示例8: OctavePlot

 public OctavePlot( DateTime[] dataX, double[] dataY)
     : this(dataX.Select(t => (double)t.Ticks).ToArray(), dataY)
 {
     someOtherCommands = "datalabels={"+
         String.Join(",",GenerateDateXTicks(8,dataX).Select(s => "'"+s+"'"))+
         "};set(gca(),'xticklabel',datalabels);";
 }
开发者ID:bellal89,项目名称:cqa_medical,代码行数:7,代码来源:OctavePlot.cs

示例9: ReturnWhateverSelect

 public void ReturnWhateverSelect()
 {
     var x = new DateTime(2012, 1, 1);
     var y = x.Select(self => new { self.Day });
     Assert.AreEqual(1, y.Day);
 }
开发者ID:joeriks,项目名称:FnX,代码行数:6,代码来源:MapTests.cs

示例10: Add_ThanhLapDV

 public bool Add_ThanhLapDV(string[] m_TenDV_Ten, string[] m_TenDVTat_Ten,
                                         int[] m_IDDVCha, string[] m_GhiChu, DateTime[] m_NgayHieuLuc)
 {
     IDataParameter[] paras = new IDataParameter[13]{
         new NpgsqlParameter("p_ma_qd",ma_qd + "_" + ngay_hieu_luc.Value.ToString("ddMMyyyy")),
         new NpgsqlParameter("p_ten_qd",ten_qd),
         new NpgsqlParameter("path",path),
         new NpgsqlParameter("path_mo_ta",pathmota),
         new NpgsqlParameter("p_ngay_ky",ngay_ky),
         new NpgsqlParameter("p_ngay_hieu_luc",ngay_hieu_luc),
         new NpgsqlParameter("p_ngay_het_han",ngay_het_han),
         new NpgsqlParameter("p_mo_ta",mota),
         new NpgsqlParameter("p_ten_don_vi_moi",m_TenDV_Ten),
         new NpgsqlParameter("p_ten_dv_moi_viet_tat",m_TenDVTat_Ten),
         new NpgsqlParameter("p_truc_thuoc_don_vi",m_IDDVCha),
         new NpgsqlParameter("p_tu_ngay",m_NgayHieuLuc.Select( a => a.ToString("d", CultureInfo.CreateSpecificCulture("vi-VN"))).ToArray()),  // format : mm/dd/yyyy),
         new NpgsqlParameter("p_ghi_chu",m_GhiChu)
     };
     try
     {
         dp.executeScalarProc("sp1_insert_thanh_lap_dv", paras);
         return true;
     }
     catch (Exception)
     {
         throw;
     }
 }
开发者ID:Fucmeo,项目名称:ou-qlns,代码行数:28,代码来源:QuyetDinh.cs


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