• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.DateTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: DateClause

        public DateClause( DateTime from, DateTime to )
        {
            DateTimeExtensions.NormalizeRange( ref from, ref to );

            From = from.Date;
            To = to.Date;
        }
开发者ID:bg0jr,项目名称:Maui,代码行数:7,代码来源:DateClause.cs


示例17: Capability

        public Capability(string issuerId, DateTime expiryTime)
        {
            this.issuerId = issuerId;
            this.expiryTime = expiryTime;

            randomVal = randGenerator.Next();
        }
开发者ID:smosgin,项目名称:labofthings,代码行数:7,代码来源:Capability.cs


示例18: Announcement

        public Announcement(string description, string type, string operatorName, DateTime? startDate, DateTime? endDate, Coordinate location, IEnumerable<string> modes)
        {
            this.OperatorName = operatorName;
            this.Description = description;
            this.StartDate = startDate;
            this.EndDate = endDate;
            this.Location = location;
            this.Type = type;
            this.Modes.AddRange(modes);
            this.RelativeDateString = TimeConverter.ToRelativeDateString(StartDate, true);

            if (modes != null)
            {
                if (modes.Select(x => x.ToLower()).Contains("bus"))
                    this.ModeImages.Add("/Images/64/W/ModeBus.png");
                if (modes.Select(x => x.ToLower()).Contains("rail"))
                    this.ModeImages.Add("/Images/64/W/ModeRail.png");
                if (modes.Select(x => x.ToLower()).Contains("taxi"))
                    this.ModeImages.Add("/Images/64/W/ModeTaxi.png");
                if (modes.Select(x => x.ToLower()).Contains("boat"))
                    this.ModeImages.Add("/Images/64/W/ModeBoat.png");

                if (!this.ModeImages.Any())
                    this.ModeImages.Add("/Images/64/W/ModeBus.png");
            }
            else
            {
                this.Modes.Add("bus");
                this.ModeImages.Add("/Images/64/W/ModeBus.png");
            }
        }
开发者ID:CodeObsessed,项目名称:drumbleapp,代码行数:31,代码来源:Announcement.cs


示例19: Update

        public override void Update()
        {
            // Bounding Box
            rectangle = new Rectangle
            (
                (int)Position.X,
                (int)Position.Y,
                (int)Size.X,
                (int)Size.Y
            );

            KeyboardState keyboardState = Keyboard.GetState();
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                Position += movingVector;
                body.ApplyLinearImpulse(movingImpulse);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                Position -= movingVector;
                body.ApplyLinearImpulse(-movingImpulse);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.W) && !prevKeyboardState.IsKeyDown(Keys.W))
            {
                if ((DateTime.Now - previousJump).TotalSeconds >= jumpInterval)
                {
                    jumpEffect.Play();
                    body.ApplyLinearImpulse(jumpingImpulse);
                    previousJump = DateTime.Now;
                }
            }

            prevKeyboardState = keyboardState;
        }
开发者ID:rolandKulcsar,项目名称:Crate-Game,代码行数:34,代码来源:Player.cs


示例20: UploadMessageAsync

        /// <inheritdoc/>
        public async Task<Uri> UploadMessageAsync(Stream content, DateTime expirationUtc, string contentType, string contentEncoding, IProgress<int> bytesCopiedProgress, CancellationToken cancellationToken = default(CancellationToken))
        {
            Requires.NotNull(content, "content");
            Requires.Range(expirationUtc > DateTime.UtcNow, "expirationUtc");

            string blobName = Utilities.CreateRandomWebSafeName(DesktopUtilities.BlobNameLength);
            if (expirationUtc < DateTime.MaxValue)
            {
                DateTime roundedUp = expirationUtc - expirationUtc.TimeOfDay + TimeSpan.FromDays(1);
                blobName = roundedUp.ToString("yyyy.MM.dd") + "/" + blobName;
            }

            var blob = this.container.GetBlockBlobReference(blobName);

            // Set metadata with the precise expiration time, although for efficiency we also put the blob into a directory
            // for efficient deletion based on approximate expiration date.
            if (expirationUtc < DateTime.MaxValue)
            {
                blob.Metadata["DeleteAfter"] = expirationUtc.ToString(CultureInfo.InvariantCulture);
            }

            blob.Properties.ContentType = contentType;
            blob.Properties.ContentEncoding = contentEncoding;

            await blob.UploadFromStreamAsync(content.ReadStreamWithProgress(bytesCopiedProgress), cancellationToken);
            return blob.Uri;
        }
开发者ID:AArnott,项目名称:IronPigeon,代码行数:28,代码来源:AzureBlobStorage.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.DateTimeRawInfo类代码示例发布时间:2022-05-26
下一篇:
C# System.Date类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap