本文整理汇总了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;
}
示例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;
}
示例3: Event
public Event(string venue, double lat, double lng, DateTime date)
{
this.Venue = venue;
this.Latitude = lat;
this.Longitude = lng;
Date = date;
}
示例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;
}
示例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
}
示例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_;
}
示例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();
}
示例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;
}
示例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);
}
}
}
示例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,
});
}
示例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]";
}
示例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();
}
示例13: GetDateTime
private string GetDateTime( DateTime val )
{
if ( val == DateTime.MinValue )
return "";
return val.ToString( "yyyy'-'MM'-'dd HH':'mm':'ss" );
}
示例14: Person
public Person(int _id, string _name, int _age, DateTime _birth)
{
ID = _id;
Name = _name;
Age = _age;
Birth = _birth;
}
示例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>();
}