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


C# System.DateTime类代码示例

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


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

示例1: AddPoint

 public Point AddPoint(float value, DateTime timestamp)
 {
     var p = new Point(value, timestamp);
     _points.Add(p);
     _lastPoint = p;
     return p;
 }
开发者ID:jasondentler,项目名称:YouTrackBurnDown,代码行数:7,代码来源:Line.cs

示例2: ComparePropertyValue

		protected override bool ComparePropertyValue(IOguObject srcOguObject, string srcPropertyName, ADObjectWrapper adObject, string targetPropertyName, string context)
		{
			DateTime dtResult = DateTime.MinValue;
			long adAccountExpiresValue = Convert.ToInt64(adObject.Properties[targetPropertyName]);

			try
			{
				if (adAccountExpiresValue != SynchronizeHelper.ACCOUNT_EXPIRES_MAX_VALUE)
				{
					if (adAccountExpiresValue != 0)
					{
						DateTime dt = DateTime.FromFileTime(adAccountExpiresValue);

						//舍弃掉毫秒
						dtResult = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, dt.Millisecond);
					}
				}
			}
			catch (System.ArgumentOutOfRangeException)
			{
				dtResult = DateTime.MaxValue;
			}

			dtResult = SynchronizeContext.Current.ADHelper.GetUserAccountExpirationDate(dtResult);
			var accountExpiresDate = Convert.ToDateTime(srcOguObject.Properties[srcPropertyName]);

			return accountExpiresDate == dtResult;
		}
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:28,代码来源:LargeIntAndDateTimePropertyComparer.cs

示例3: Event

		public Event(string venue, double lat, double lng, DateTime date)
		{
			this.Venue = venue;
			this.Latitude = lat;
			this.Longitude = lng;
			Date = date;
		}
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:Event.cs

示例4: Create

        /// <summary>
        /// Inserts a row in the mp_ContentWorkflow table. Returns rows affected count.
        /// </summary>
        /// <param name="guid"> guid </param>
        /// <param name="siteGuid"> siteGuid </param>
        /// <param name="moduleGuid"> moduleGuid </param>
        /// <param name="createdDateUtc"> createdDateUtc </param>
        /// <param name="userGuid"> userGuid </param>
        /// <param name="status"> status </param>
        /// <param name="contentText"> contentText </param>
        /// <param name="customData"> customData </param>
        /// <param name="customReferenceNumber"> customReferenceNumber </param>
        /// <param name="customReferenceGuid"> customReferenceGuid </param>
        /// <returns>int</returns>
        public static int Create(
            Guid guid,
            Guid siteGuid,
            Guid moduleGuid,
            Guid userGuid,
            DateTime createdDateUtc,
            string contentText,
            string customData,
            int customReferenceNumber,
            Guid customReferenceGuid,
            string status)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_ContentWorkflow_Insert", 10);
            sph.DefineSqlParameter("@Guid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, guid);
            sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
            sph.DefineSqlParameter("@ModuleGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, moduleGuid);
            sph.DefineSqlParameter("@CreatedDateUtc", SqlDbType.DateTime, ParameterDirection.Input, createdDateUtc);
            sph.DefineSqlParameter("@UserGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, userGuid);
            sph.DefineSqlParameter("@Status", SqlDbType.NVarChar, 20, ParameterDirection.Input, status);
            sph.DefineSqlParameter("@ContentText", SqlDbType.NVarChar, -1, ParameterDirection.Input, contentText);
            sph.DefineSqlParameter("@CustomData", SqlDbType.NVarChar, -1, ParameterDirection.Input, customData);

            //object customReferenceNumberVal = customReferenceNumber.HasValue ? (object)customReferenceNumber.Value : DBNull.Value;
            sph.DefineSqlParameter("@CustomReferenceNumber", SqlDbType.Int, ParameterDirection.Input, customReferenceNumber);

            //object customReferenceGuidVal = customReferenceGuid.HasValue ? (object)customReferenceGuid.Value : DBNull.Value;
            sph.DefineSqlParameter("@CustomReferenceGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, customReferenceGuid);

            int rowsAffected = sph.ExecuteNonQuery();
            return rowsAffected;
        }
开发者ID:joedavis01,项目名称:mojoportal,代码行数:45,代码来源:DBContentWorkflow.cs

示例5: TraceEventCache

		public TraceEventCache ()
			{
#if SSHARP
			started = DateTimePrecise.Now;
#else
			started = DateTime.Now;
#endif
#if NETCF
			try
				{
				throw new ApplicationException ();
				}
			catch (ApplicationException aex)
				{
				callstack = aex.StackTrace;
				}
#else
			manager = Trace.CorrelationManager;
			callstack = Environment.StackTrace;
#endif
			timestamp = Stopwatch.GetTimestamp ();
#if SSHARP
			process = (int)Crestron.SimplSharp.InitialParametersClass.ApplicationNumber;
#if SSHARP_PRO
			thread = CurrentThread.Name;
#else
			thread = String.Empty;
#endif
#else
			thread = Thread.CurrentThread.Name;
			process = Process.GetCurrentProcess ().Id;
#endif
			}
开发者ID:oznetmaster,项目名称:SSMonoDiagnosticsLibrary,代码行数:33,代码来源:TraceEventCache.cs

示例6: StudyDeleteRecord

 public StudyDeleteRecord(
      String _studyInstanceUid_
     ,DateTime _timestamp_
     ,String _serverPartitionAE_
     ,ServerEntityKey _filesystemKey_
     ,String _backupPath_
     ,String _reason_
     ,String _accessionNumber_
     ,String _patientId_
     ,String _patientsName_
     ,String _studyId_
     ,String _studyDescription_
     ,String _studyDate_
     ,String _studyTime_
     ,XmlDocument _archiveInfo_
     ,String _extendedInfo_
     ):base("StudyDeleteRecord")
 {
     StudyInstanceUid = _studyInstanceUid_;
     Timestamp = _timestamp_;
     ServerPartitionAE = _serverPartitionAE_;
     FilesystemKey = _filesystemKey_;
     BackupPath = _backupPath_;
     Reason = _reason_;
     AccessionNumber = _accessionNumber_;
     PatientId = _patientId_;
     PatientsName = _patientsName_;
     StudyId = _studyId_;
     StudyDescription = _studyDescription_;
     StudyDate = _studyDate_;
     StudyTime = _studyTime_;
     ArchiveInfo = _archiveInfo_;
     ExtendedInfo = _extendedInfo_;
 }
开发者ID:nhannd,项目名称:Xian,代码行数:34,代码来源:StudyDeleteRecord.gen.cs

示例7: GetTembloresByDate

 public Temblor[] GetTembloresByDate(DateTime fecha)
 {
     var temblores = from t in repository.All<Temblor>()
                     where t.Fecha >= fecha.Date && t.Fecha < fecha.Date.AddDays(1)
                     select t;
     return temblores.ToArray();
 }
开发者ID:mariochavez,项目名称:Cesun,代码行数:7,代码来源:DataServiceSubSonic.cs

示例8: Add

 public static int Add(
     Guid pollGuid,
     Guid siteGuid,
     String question,
     bool anonymousVoting,
     bool allowViewingResultsBeforeVoting,
     bool showOrderNumbers,
     bool showResultsWhenDeactivated,
     bool active,
     DateTime activeFrom,
     DateTime activeTo)
 {
     SqlParameterHelper sph = new SqlParameterHelper(ConnectionString.GetWriteConnectionString(), "mp_Polls_Insert", 10);
     sph.DefineSqlParameter("@PollGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, pollGuid);
     sph.DefineSqlParameter("@SiteGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, siteGuid);
     sph.DefineSqlParameter("@Question", SqlDbType.NVarChar, 255, ParameterDirection.Input, question);
     sph.DefineSqlParameter("@AnonymousVoting", SqlDbType.Bit, ParameterDirection.Input, anonymousVoting);
     sph.DefineSqlParameter("@AllowViewingResultsBeforeVoting", SqlDbType.Bit, ParameterDirection.Input, allowViewingResultsBeforeVoting);
     sph.DefineSqlParameter("@ShowOrderNumbers", SqlDbType.Bit, ParameterDirection.Input, showOrderNumbers);
     sph.DefineSqlParameter("@ShowResultsWhenDeactivated", SqlDbType.Bit, ParameterDirection.Input, showResultsWhenDeactivated);
     sph.DefineSqlParameter("@Active", SqlDbType.Bit, ParameterDirection.Input, active);
     sph.DefineSqlParameter("@ActiveFrom", SqlDbType.DateTime, ParameterDirection.Input, activeFrom);
     sph.DefineSqlParameter("@ActiveTo", SqlDbType.DateTime, ParameterDirection.Input, activeTo);
     int rowsAffected = sph.ExecuteNonQuery();
     return rowsAffected;
 }
开发者ID:saiesh86,项目名称:TravelBlog,代码行数:26,代码来源:DBPoll.cs

示例9: CanStoreAndRetrieveTime

		public void CanStoreAndRetrieveTime(DateTime expectedTime)
		{
			//  Only supporting accuracy up to the millisecond
			expectedTime = new DateTime(expectedTime.Year, expectedTime.Month, expectedTime.Day, expectedTime.Hour, expectedTime.Minute, expectedTime.Second, expectedTime.Millisecond, expectedTime.Kind);

			using (var store = NewDocumentStore())
			{
				using (var session = store.OpenSession())
				{
					session.Store(new Post
					{
						PostedAt = expectedTime,
						Tags = new List<string> { "C#", "Programming", "NoSql" }
					});
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var posts = session.Query<Post>()
						.Customize(q => q.WaitForNonStaleResultsAsOfNow(TimeSpan.FromSeconds(5)))
						.ToArray();

					Assert.Equal(1, posts.Length);
					Assert.Equal(expectedTime, posts[0].PostedAt);
				}
			}
		}
开发者ID:nhsevidence,项目名称:ravendb,代码行数:28,代码来源:TagCloud.cs

示例10: SetCookie

 /// <summary>
 /// Sets a persistent cookie with an expiresAt date
 /// </summary>
 public static void SetCookie(this IHttpResponse httpRes, string cookieName,
     string cookieValue, DateTime expiresAt, string path = "/")
 {
     httpRes.Cookies.AddCookie(new Cookie(cookieName, cookieValue, path) {
         Expires = expiresAt,
     });
 }
开发者ID:niemyjski,项目名称:ServiceStack,代码行数:10,代码来源:HttpResponseExtensions.cs

示例11: ConvertToDisplayDateTime

 protected static string ConvertToDisplayDateTime(DateTime? utcDateTime)
 {
     // You can change this method to convert the UTC date time into the desired display
     // offset and format. Here we're converting it to the server timezone and formatting
     // as a short date and a long time string, using the current thread culture.
     return utcDateTime.HasValue ? utcDateTime.Value.ToLocalTime().ToString("G") : "[never]";
 }
开发者ID:BridgetechCorp,项目名称:Report,代码行数:7,代码来源:Manage.aspx.cs

示例12: GetEvents

        /// <summary>
        /// Queries the calendar for events matching the specified criteria.
        /// </summary>
        /// <param name="fullTextQuery"></param>
        /// <param name="from"></param>
        /// <param name="until"></param>
        /// <returns></returns>
        public CalendarEvent[] GetEvents(string fullTextQuery, DateTime? from, DateTime? until)
        {
            EventQuery query = new EventQuery();

            query.Uri = new Uri(CALENDAR_URI);

            query.Query = fullTextQuery;

            if (from != null)
            {
                query.StartTime = from.Value;
            }

            if (until != null)
            {
                query.EndTime = until.Value;
            }

            EventFeed calFeed = _service.Query(query);

            List<CalendarEvent> events = CollectionUtils.Map<EventEntry, CalendarEvent, List<CalendarEvent>>(calFeed.Entries,
                delegate(EventEntry e) { return new CalendarEvent(e); });
            events.Sort();
            return events.ToArray();
        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:32,代码来源:Calendar.cs

示例13: GetDateTime

		private string GetDateTime( DateTime val )
		{
			if ( val == DateTime.MinValue )
				return "";

			return val.ToString( "yyyy'-'MM'-'dd HH':'mm':'ss" );
		}
开发者ID:greeduomacro,项目名称:GoUO,代码行数:7,代码来源:HouseGumpAOS.cs

示例14: Person

 public Person(int _id, string _name, int _age, DateTime _birth)
 {
     ID = _id;
     Name = _name;
     Age = _age;
     Birth = _birth;
 }
开发者ID:Rafael-Miceli,项目名称:ProjectStudiesCert70-536,代码行数:7,代码来源:Program.cs

示例15: Produire

        // Calcul des refinancements
        public IQueryable<Refinancement> Produire(DateTime dateArchivage)
        {
            // INitialisation des budgets
            IQueryable<Budget> _budgets = uow.Budget
                .GetAllByGroupeId(groupeId)
                .Include(b => b.BudgetEquilibre)
                .Where(b => b.IsActive == true)
                .Where(b => b.RefinancementImmediat == true)
                .Where(b => b.TypeNonAlloue != true) // Exclusion des budgets de type 'non alloué'
                ;

            // Calculs des écarts
            var _budgetsHorsReserve = _budgets.Where(b => b.IsBudgetEquilibre != true); // Exclusion des budgets de type réserve de financement (Budget equilibre)
            IList<Refinancement> _refis = fabriqueRefi.Make(_budgetsHorsReserve, dateArchivage);

            // Il faut maintenant ajouter les budgets réserve
            var _reserves = _budgets.Where(b => b.IsBudgetEquilibre == true);
            IList<Refinancement> _refiReserves = fabriqueRefi.Make(_reserves, dateArchivage);
            CalculerRefinancementReserves(_refis, _refiReserves);

            // Retour
            return _refis
                .Where(e => e.MontantRefinancement != 0)
                .OrderBy(e => e.MontantEcart)
                .AsQueryable<Refinancement>();
        }
开发者ID:paulkornikov,项目名称:Pragonas,代码行数:27,代码来源:RefinancementServices.cs


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