當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。