public void Setup() { StreamFactory sf = StreamFactory.Instance; DateTime Date = new DateTime(DateTime.UtcNow.Ticks); string HomeName = String.Format("TestHome-{0}", Date.ToString("yyyy-MM-dd")); string Caller = String.Format("{0}", Date.ToString("HH-mm-ss")); string AppName = Caller; Random rnd = new Random(); string StreamName = String.Format("{0}", rnd.Next()); FqStreamID fqstreamid = new FqStreamID(HomeName, AppName, StreamName); CallerInfo ci = new CallerInfo(null, Caller, Caller, 1); sf.deleteStream(fqstreamid, ci); vds = sf.openValueDataStream<StrKey, ByteValue>(fqstreamid, ci, null, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Write, mdserveraddress: "http://localhost:23456/MetadataServer"); k1 = new StrKey("k1"); k2 = new StrKey("k2"); }
private void SetInitInputTime(DateTime time) { Configuration cfg = WebConfigurationManager.OpenWebConfiguration("~"); cfg.AppSettings.Settings[theKeyName].Value = time.ToString(); cfg.Save(); Label1.Text = "初始录入结束时间已设置为" + time.ToString(); }
public async Task<SearchResult> GetConnections(string from, string to, DateTime time, bool isArrival = false) { // Check for network connectivity if (!NetworkInterface.GetIsNetworkAvailable()) return null; var client = new RestClient("http://transport.opendata.ch/v1/"); var request = new RestRequest("connections") .AddParameter("from", from) .AddParameter("to", to) .AddParameter("date", time.ToString("yyyy-MM-dd")) .AddParameter("time", time.ToString("HH:mm")) .AddParameter("isArrivalTime", isArrival ? 1 : 0); try { return await client .ExecutTaskAsync(request) .ContinueWith(task => JObject.Parse(task.Result.Content).ToObject<SearchResult>()); } catch (Exception) { return null; } }
//private static readonly AsyncLock Mutex = new AsyncLock (); public async static Task SaveEngagementNotesRecord (DateTime timeStamp, int gymID, int profileID, string note, int engagementNoteID, int userID, string staffName) { var db = DependencyService.Get<ISQLite> ().GetAsyncConnection (); await db.CreateTableAsync<EngagementNotes> (); var currentRecord = await db.Table<EngagementNotes> ().Where (row => row.EngagementNoteID == engagementNoteID).FirstOrDefaultAsync (); if (currentRecord != null && currentRecord.Id != 0) { currentRecord.DateTime = timeStamp.ToString (); currentRecord.GymID = gymID; currentRecord.Note = note; currentRecord.ProfileID = profileID; currentRecord.EngagementNoteID = engagementNoteID; currentRecord.UserID = userID; currentRecord.StaffName = staffName; await db.UpdateAsync (currentRecord); } else { EngagementNotes engagementNote = new EngagementNotes (); engagementNote.DateTime = timeStamp.ToString (); engagementNote.GymID = gymID; engagementNote.Note = note; engagementNote.ProfileID = profileID; engagementNote.EngagementNoteID = engagementNoteID; engagementNote.UserID = userID; engagementNote.StaffName = staffName; await db.InsertAsync (engagementNote); } }
public async Task<ConstructGenGen<string, double>> GetAsConstruct(DateTime date_, CarbonClient cc_) { var moniker = string.Format("ssys.covariance_matrix.15.2.{0}", date_.ToString("yyyyMMdd")); ConstructGenGen<string, double> con; try { con = await DataFrameHelper.GetDataFrameCellByCell( name_: moniker, keyExtractor_: (x) => (string)x, valueExtractor_: (vals) => { double ret = 0d; if (vals is IConvertible) ret = Convert.ToDouble(vals) * 252d; return ret; }, cc_: cc_); } catch (Exception ex_) { Logger.Error(string.Format("Error getting covariance for date [{0}]", date_.ToString("dd-MMM-yyyy")), typeof(Covariances), ex_); con = null; } return con; }
/// <summary> /// 格式化日期时间 /// </summary> /// <param name="dateTime1">日期时间</param> /// <param name="dateMode">显示模式</param> /// <returns>0-9种模式的日期</returns> public static string FormatDate(DateTime dateTime1, string dateMode) { switch (dateMode) { case "0": return dateTime1.ToString("yyyy-MM-dd"); case "1": return dateTime1.ToString("yyyy-MM-dd HH:mm:ss"); case "2": return dateTime1.ToString("yyyy/MM/dd"); case "3": return dateTime1.ToString("yyyy年MM月dd日"); case "4": return dateTime1.ToString("MM-dd"); case "5": return dateTime1.ToString("MM/dd"); case "6": return dateTime1.ToString("MM月dd日"); case "7": return dateTime1.ToString("yyyy-MM"); case "8": return dateTime1.ToString("yyyy/MM"); case "9": return dateTime1.ToString("yyyy年MM月"); default: return dateTime1.ToString(); } }
/// <summary> /// Реализует перевод даты-времени в необходимое строкове представление. /// </summary> /// <param name="dt"></param> /// <returns>Возвращает строковое представление даты.</returns> public static string Convert(DateTime dt) { if (dt.Hour == 0 && dt.Minute == 0 && dt.Second == 0) return dt.ToString(DateFormat, CultureInfo.InvariantCulture); return dt.ToString(DateAndTime, CultureInfo.InvariantCulture); }
public bool makeReservation(string sStartCityCode, string sEndCityCode, DateTime dtFlightDate, PassengerInfo[] passengers, PaymentInfo pInfo) { Console.WriteLine("Making reservation for {0} to {1} on {2} for {3} Passengers", sStartCityCode, sEndCityCode, dtFlightDate.ToString(), passengers.Count()); if (DateTime.Compare(dtFlightDate, DateTime.Now) <= 0) return false; List<Flight_DAL.Route> lstRoutes; bool bStatus = false; lock (this) { lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode); } if (lstRoutes != null) { Console.WriteLine("Obtained the list of routes. Count - " + lstRoutes.Count); Route r = (from ro in lstRoutes where ro.FlightTime.Equals(dtFlightDate.ToString("HH:mm")) select ro).FirstOrDefault(); if (r != null) { Console.WriteLine("Obtained the route information"); List<Passenger> lstPassengers = getPassengerList(passengers); string sReservationID; lock (this) { sReservationID = myFlightBLL.getFlightBLLInstance().reserveFlight(r.RouteID, dtFlightDate, lstPassengers); bStatus = myFlightBLL.getFlightBLLInstance().makePayment(sReservationID, getPaymentDetails(pInfo)); } } } return bStatus; //default value }
public DipsQueue CreateNewDipsQueue( DipsLocationType locationType, string batchNumber, string documentReferenceNumber, DateTime processingDate, string jobIdentifier, string jobId) { var imagePath = string.Format(@"{0}\{1}", adapterConfiguration.ImagePath, batchNumber.Substring(0, 5)); if (string.IsNullOrEmpty(jobId)) { jobId = DipsJobIdType.NabChqPod.Value; } if (WorkTypeEnum.NABCHQ_POD.ToString().Equals(jobId)) { jobId = DipsJobIdType.NabChqPod.Value; } // temporary fix to enable for value testing - uncomment if required //if (WorkTypeEnum.BQL_POD.ToString().Equals(jobId)) //{ // jobId = WorkTypeEnum.NABCHQ_INWARDFV.ToString(); //} var output = new DipsQueue { //Dynamic DipsQueue Values S_BATCH = batchNumber, S_TRACE = documentReferenceNumber.PadLeft(9, '0'), S_SDATE = processingDate.ToString("dd/MM/yy"), S_STIME = processingDate.ToString("HH:mm:ss"), S_SELNSTRING = GenerateSelectionString(processingDate, batchNumber), //Default DipsQueue Values S_LOCATION = locationType.Value.PadRight(33, ' '), S_PINDEX = GeneratePriorityIndex(), S_LOCK = "0".PadLeft(10, ' '), S_CLIENT = DipsClientType.NabChq.Value.PadRight(80, ' '), //S_JOB_ID = DipsJobIdType.NabChqPod.Value.PadRight(128, ' '), S_JOB_ID = jobId.PadRight(128, ' '), S_MODIFIED = "0".PadLeft(5, ' '), S_COMPLETE = "0".PadLeft(5, ' '), S_PRIORITY = adapterConfiguration.DipsPriority.PadLeft(5, ' '), S_IMG_PATH = imagePath.PadRight(80, ' '), S_VERSION = adapterConfiguration.Dbioff32Version.PadRight(32, ' '), //Ignored fields S_UTIME = string.Empty.PadLeft(10, ' '), S_LOCKUSER = string.Empty.PadLeft(17, ' '), S_LOCKMODULENAME = string.Empty.PadLeft(17, ' '), S_LOCKUNITID = string.Empty.PadLeft(10, ' '), S_LOCKMACHINENAME = string.Empty.PadLeft(17, ' '), S_LOCKTIME = string.Empty.PadLeft(10, ' '), S_PROCDATE = string.Empty.PadLeft(9, ' '), S_REPORTED = string.Empty.PadLeft(5, ' '), }; return output; }
public void AddWorkLog(string issueRef, WorkLogStrategy workLogStrategy, string comment, TimeSpan timeSpent, DateTime logDate, TimeSpan? remainingTime = null) { if (logDate.Kind != DateTimeKind.Local) logDate = DateTime.SpecifyKind(logDate, DateTimeKind.Local); var postData = new Dictionary<string, object> { { "started", $"{logDate.ToString("yyyy-MM-ddTHH:mm:ss.fff")}{logDate.ToString("zzz").Replace(":", "")}"}, { "comment", comment }, { "timeSpent", $"{timeSpent.Hours}h {timeSpent.Minutes}m"}, }; var adjustmentMethod = string.Empty; var newEstimate = string.Empty; if (remainingTime.HasValue) { newEstimate = $"{remainingTime.Value.Hours}h {remainingTime.Value.Minutes}m"; } switch (workLogStrategy) { case WorkLogStrategy.Automatic: adjustmentMethod = "auto"; break; case WorkLogStrategy.LeaveRemaining: adjustmentMethod = "leave"; break; case WorkLogStrategy.SetValue: adjustmentMethod = "new"; break; } restClient.Post(HttpStatusCode.Created, $"issue/{issueRef}/worklog?adjustEstimate={adjustmentMethod}&newEstimate={newEstimate}&reduceBy=", postData); }
public void IncludeHours_WhenInvoked_ShouldIncludeHours(DateTime subject) { subject.AsDateTime().IncludeHours().With12HrSingleDigit().Format().ShouldEqual(subject.ToString("%h")); subject.AsDateTime().IncludeHours().With12HrDoubleDigit().Format().ShouldEqual(subject.ToString("hh")); subject.AsDateTime().IncludeHours().With24HrSingleDigit().Format().ShouldEqual(subject.ToString("%H")); subject.AsDateTime().IncludeHours().With24HrDoubleDigit().Format().ShouldEqual(subject.ToString("HH")); }
protected string DateTimeToString(DateTime datetime, bool dateOnly) { if (dateOnly) return datetime.ToString("yyyy-MM-dd"); else return datetime.ToString("yyyy-MM-dd HH:mm:ss.fff"); }
public static string TimeStampDiv(DateTime aDateTime, string aDivCssClass, string aPaddingDivCssClass, string aContentDivCssClass, string aDateTimeStampMonthFormat, string aDateTimeStampDayFormat) { var myTimeStampDiv = new TagBuilder("div"); myTimeStampDiv.AddCssClass(aDivCssClass); var myTimeStampPad = new TagBuilder("div"); myTimeStampPad.AddCssClass(aPaddingDivCssClass); var myTimeStampContentDiv = new TagBuilder("div"); myTimeStampContentDiv.AddCssClass(aContentDivCssClass); var myTimeStampSpan = new TagBuilder("span"); myTimeStampSpan.InnerHtml = aDateTime.ToString(aDateTimeStampMonthFormat).ToUpper(); myTimeStampContentDiv.InnerHtml = myTimeStampSpan.ToString(); myTimeStampContentDiv.InnerHtml += " "; myTimeStampContentDiv.InnerHtml += aDateTime.ToString(aDateTimeStampDayFormat); myTimeStampPad.InnerHtml = myTimeStampContentDiv.ToString(); myTimeStampDiv.InnerHtml += myTimeStampPad.ToString(); myTimeStampDiv.InnerHtml += SharedStyleHelper.ClearDiv(); return myTimeStampDiv.ToString(); }
public static int SaveEdition(DateTime dt) { try { DataSet ds = ExecuteQuery("select id_edition from edition where date_edition='" + dt.ToString() + "'"); if (ds.Tables[0].Rows.Count != 0) { return -2; } else { int q = ExecuteNonQuery("insert into edition (date_edition) values ('" + dt.ToString() + "')"); if (q == -1) { return q; } else { return 1; } } } catch (Exception e) { e.ToString(); return -99; } }
public List<FileInfo> ZemiFajlovi(string pateka, TipFajlovi tip, DateTime kojDatum) { List<FileInfo> lstFajlovi = new List<FileInfo>(); var lstFajl = ZemiFajlovi(pateka,tip); foreach (FileInfo fiPom in lstFajl) { if (fiPom.LastWriteTime.Date >= kojDatum || fiPom.CreationTime.Date>=kojDatum) { lstFajlovi.Add(fiPom); } } if (lstFajlovi.Count == 0) { _status.addInfo(TipServisi.FileService, "Nema fajlovi za kopiranje za IZBRANIOT DATUM("+ kojDatum.ToString("dd-MM-yyyy") +")! => Fajlovi(" + tip.ToString().ToUpper() + ") => " + pateka); } else { _status.addInfo(TipServisi.FileService, lstFajlovi.Count.ToString() + " fajlovi(" + tip.ToString().ToUpper() + ") za IZBRANIOT DATUM(" + kojDatum.ToString("dd-MM-yyyy") + ")!"); _status.addLog("File", tip.ToString().ToUpper() + ":" + lstFajlovi.Count.ToString() + " fajlovi za IZBRANIOT DATUM(" + kojDatum.ToString("dd-MM-yyyy") + ")!"); } return lstFajlovi; }
public MembershipCreateStatus CreateEvent(string ID, string EventType,DateTime EventDate,string Remarks) { try { int intUserId =Convert.ToInt32(HttpContext.Current.Session["LoginUserId"]); if (String.IsNullOrEmpty(EventType)) throw new ArgumentException("Value cannot be null or empty.", "EventType"); if (default(DateTime) == (EventDate)) throw new ArgumentException("Value cannot be null or empty.", "EventDate"); //Insert string strSQL = ""; if (ID == "0" || ID == "" || ID==null) strSQL = "INSERT INTO tbEvents VALUES(" + intUserId + ", '" + EventType + "', '" + EventDate.ToString("MM/dd/yyyy") + "', '" + (Remarks == "" ? " " : Remarks) + "')"; else strSQL = "UPDATE tbEvents SET intUserId=" + intUserId + ", EventType='" + EventType + "', EventDate='" + EventDate.ToString("MM/dd/yyyy") + "', Remarks='" + (Remarks == "" ? " " : Remarks) + "' WHERE ID=" + ID; new SQLData().ExecuteQuery(strSQL); return MembershipCreateStatus.Success; } catch (Exception) { throw new ArgumentException("Error in save event details.", "EventType"); } }
private static void BuildReport() { string connectionString = ThemeRepositoryFactory.Default.ConnectionProvider.GetWriteConnectionString(); //获取当前报表统计表中已经统计到的日期 DateTime lastDate = new DateTime(2010, 5, 22); string cmdText = "SELECT MAX(ReportDate) FROM VisitorsDayReport"; object result = SqlHelper.ExecuteScalar(connectionString, System.Data.CommandType.Text, cmdText); if (result != DBNull.Value && Convert.ToInt32(result) > 0) { lastDate = DateTime.ParseExact(result.ToString(), "yyyyMMdd", null).AddDays(1); } //开始统计从上个统计日到今天的所有数据 while (lastDate < DateTime.Now.Date) { cmdText = string.Format(CMD_ALL_USER_COUNT, lastDate.ToString("yyyyMMdd"), lastDate.AddDays(1).ToString("yyyyMMdd")); int allUserCount = Convert.ToInt32(SqlHelper.ExecuteScalar(connectionString, System.Data.CommandType.Text, cmdText)); cmdText = string.Format(CMD_OLD_USER_COUNT, lastDate.ToString("yyyyMMdd"), lastDate.AddDays(1).ToString("yyyyMMdd")); int oldUserCount = Convert.ToInt32(SqlHelper.ExecuteScalar(connectionString, System.Data.CommandType.Text, cmdText)); cmdText = string.Format(CMD_INSERT_REPORT_DATA , allUserCount , oldUserCount , lastDate.ToString("yyyyMMdd") ); SqlHelper.ExecuteNonQuery(connectionString, System.Data.CommandType.Text, cmdText); Console.WriteLine(string.Format("计算完成{0}日的统计,所有用户:{1},老用户:{2}", lastDate, allUserCount, oldUserCount)); lastDate = lastDate.AddDays(1); } }
public void FirstAfter(DateTime timestamp) { using (NpgsqlConnection conn = Connection ()) { conn.Open (); Console.WriteLine ("time i'm shooting for: " + timestamp.ToString ()); string timestampStr = timestamp.ToString (dbTimeFormat); bool forward = true; bool back = false; Screenshot screenshot = GetNextPrevNote (conn, timestampStr, forward, timeCheckTypeFilters); if (screenshot == null) { Console.WriteLine ("time i'm shooting for: -> note is null"); screenshot = GetNextPrevNote (conn, timestampStr, back, timeCheckTypeFilters); } else { Console.WriteLine ("time i'm shooting for: -> note not null"); } if (screenshot != null) { currentScreenshot = screenshot; setNoteDataFileIfAvailible (conn, currentScreenshot); sendTimeToTimeblockAdder (currentScreenshot); } else { Console.WriteLine ("time i'm shooting for: -> note null again"); } conn.Close (); } }
private static void PrintCalendar(int month, int year) { //Console.OutputEncoding = System.Text.Encoding.Unicode; DateTime dt = new DateTime(year, month, 1); DateTime next = dt.AddMonths(1); Console.WriteLine(dt.ToString("MMMM")); for (int i = 0; i <= 6; i++) { Console.Write(dt.ToString("dddd").PadRight(15)); dt = dt.AddDays(1); } dt = new DateTime(year, month, 1); int whenItsSunday = 7; Console.WriteLine(); for (DateTime current = dt; current < next; current=current.AddDays(1)) { Console.Write(current.Day.ToString().PadRight(15)); if (whenItsSunday == current.Day) { Console.WriteLine(); whenItsSunday += 7; } } Console.WriteLine(); }
protected static string ConvertDateTime(string dataType, DateTime value) { if (dataType == "DATE" || dataType == "NEWDATE") return value.ToString("yyyy-MM-dd"); else return value.ToString("yyyy-MM-dd HH:mm:ss"); }
private void ProcessDayForecastCollection(int daysInMonth, DateTime dateTimeItem, IList<DayForecast> dateTimeCollection) { for (var i = 1; i <= daysInMonth; i++) { bool canAddDay = true; var dayForecastItem = new DateTime(dateTimeItem.Year, dateTimeItem.Month, i); if (_dayForecastConfiguration != null) { if(_dayForecastConfiguration.WeekDaysToExclude != null) { string day = dayForecastItem.ToString("dddd"); if (_dayForecastConfiguration.WeekDaysToExclude.Contains(day)) canAddDay = false; } } if (canAddDay) { _totalDays++; dateTimeCollection.Add(new DayForecast { FullDayOfTheWeek = dayForecastItem.ToString("dddd"), FullMonth = dayForecastItem.ToString("MMMM"), Year = dayForecastItem.Year, DayOfTheMonth = dayForecastItem.Day, ShortDayOfTheWeek = dayForecastItem.ToString("ddd"), ShortMonth = dayForecastItem.ToString("MMM"), TotalHours = _dayForecastConfiguration.DefaultHoursInDay, TotalMinutes = _dayForecastConfiguration.DefaultHoursInDay * 60, TotalSeconds = (_dayForecastConfiguration.DefaultHoursInDay * 60) * 60 }); } } }
public Month GenerateCalendarData(DateTime now) { ViewBag.CurrentMonth = now.ToString("MMMM"); ViewBag.CurrentMonthInt = now.ToString("MM"); ViewBag.CurrentYear = now.ToString("yyyy"); ViewBag.NextMonth = new DateTime(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt), 1).AddMonths(1).Month; ViewBag.PrevMonth = new DateTime(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt), 1).AddMonths(-1).Month; ViewBag.NextYear = new DateTime(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt), 1).AddMonths(1).Year; ViewBag.PrevYear = new DateTime(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt), 1).AddMonths(-1).Year; Week week = new Week(); Month month = new Month(int.Parse(ViewBag.CurrentMonthInt), ViewBag.CurrentMonth, int.Parse(ViewBag.CurrentYear)); for (int i = 1; i <= DateTime.DaysInMonth(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt)); i++) { DateTime dt = new DateTime(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt), i); Day day = new Day(dt); day.Shifts = shiftService.GetShiftForDay(day).ToList(); week.Days.Add(day); if (dt.DayOfWeek == DayOfWeek.Sunday || i == DateTime.DaysInMonth(int.Parse(ViewBag.CurrentYear), int.Parse(ViewBag.CurrentMonthInt))) { month.Weeks.Add(week); week = new Week(); } } ViewBag.WeekDayCount = 0; return month; }
private string DateTimeSql(DateTime dateTime) { return String.Format("'{0}'", Column.DbType == DbType.Date ? dateTime.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : dateTime.ToString("yyyy-MM-dd HH:mm:ss.ffff", CultureInfo.InvariantCulture)); }
public static void CreateEvent(string calendarName, string id, string title, DateTime date, int status, long ownerId) { int calID = CalendarId(calendarName); if (SimilarEventExists(calID, title, date)) { // MLW TODO remove these SMap.GetLogger().Trace("An event already exists for " + calendarName + "; Name:" + title + "; ID=" + id + "; " + date.ToString()); return; } else { SMap.GetLogger().Trace("Adding a new event for " + calendarName + "; Name:" + title + "; ID=" + id + "; " + date.ToString()); } CalendarEvent.NameFromEventId(id); DnDSignUpEntities entities = new DnDSignUpEntities(); Event e = new Event(); e.EventId = id; e.Title = title; e.AllDay = true; e.CalendarId = calID; e.StartTime = date; e.EndTime = date; e.Status = status; e.OwnerId = ownerId; entities.Events.Add(e); entities.SaveChanges(); }
public static string RenderDate(DateTime dateToRender) { // +++TODO: A naive, temporary approach. // We're going to need to also support partial seconds, and possibly non-UTC times if from external sources // that decided to give us non-UTC times. return string.Format("{0}T{1}Z", dateToRender.ToString("yyyy-MM-dd"), dateToRender.ToString("HH:mm:ss")); }
public void CalculateDateMath() { using (ExcelPackage package = new ExcelPackage()) { var worksheet = package.Workbook.Worksheets.Add("Test"); var dateCell = worksheet.Cells[2, 2]; var date = new DateTime(2013, 1, 1); dateCell.Value = date; var quotedDateCell = worksheet.Cells[2, 3]; quotedDateCell.Formula = $"\"{date.ToString("d")}\""; var dateFormula = "B2"; var dateFormulaWithMath = "B2+1"; var quotedDateFormulaWithMath = $"\"{date.ToString("d")}\"+1"; var quotedDateReferenceFormulaWithMath = "C2+1"; var expectedDate = 41275.0; // January 1, 2013 var expectedDateWithMath = 41276.0; // January 2, 2013 Assert.AreEqual(expectedDate, worksheet.Calculate(dateFormula)); Assert.AreEqual(expectedDateWithMath, worksheet.Calculate(dateFormulaWithMath)); Assert.AreEqual(expectedDateWithMath, worksheet.Calculate(quotedDateFormulaWithMath)); Assert.AreEqual(expectedDateWithMath, worksheet.Calculate(quotedDateReferenceFormulaWithMath)); var formulaCell = worksheet.Cells[2, 4]; formulaCell.Formula = dateFormulaWithMath; formulaCell.Calculate(); Assert.AreEqual(expectedDateWithMath, formulaCell.Value); formulaCell.Formula = quotedDateReferenceFormulaWithMath; formulaCell.Calculate(); Assert.AreEqual(expectedDateWithMath, formulaCell.Value); } }
static public string CreateReportFile(Contact supplier, DateTime fromDate, DateTime toDate) { DataView view = BillingDS.GetBills(fromDate, toDate, "[BillType] IN('B','G') AND [BillStatus] <> 'X' AND " + "[CancelationTime] > '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "'"); string fileContents = GetReportFileSection(view, "1", "I"); // Active bills view = BillingDS.GetBills(DateTime.Parse("31/12/2011"), fromDate.AddSeconds(-0.5), "[BillType] = 'B' AND [BillStatus] = 'C' AND [CancelationTime] >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " + "[CancelationTime] <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "'"); fileContents += GetReportFileSection(view, "0", "I"); // Canceled bills view = BillingDS.GetBills(fromDate, toDate, "[BillType] IN ('C','L') AND [BillStatus] = 'A'"); fileContents += GetReportFileSection(view, "1", "E"); // Active credit notes view = BillingDS.GetBills(DateTime.Parse("31/12/2011"), fromDate.AddSeconds(-0.5), "[BillType] IN ('C','L') AND [BillStatus] = 'C' AND [CancelationTime] >= '" + fromDate.ToString("yyyy-MM-dd") + "' AND " + "[CancelationTime] <= '" + toDate.ToString("yyyy-MM-dd HH:mm:ss") + "'"); fileContents += GetReportFileSection(view, "0", "E"); // Canceled credit notes fileContents = fileContents.TrimEnd(System.Environment.NewLine.ToCharArray()); string fileName = GetReportFileName(toDate); System.IO.File.WriteAllText(fileName, fileContents); return fileName; }
public static HtmlString LogItemDate(DateTime p_Date) { if (p_Date >= DateTime.Today) { return new HtmlString(p_Date.ToShortTimeString()); } if (p_Date >= DateTime.Today.AddDays(-1)) { return new HtmlString("Yesterday, " + p_Date.ToShortTimeString()); } if (p_Date >= DateTime.Today.AddDays(-7)) { return new HtmlString(p_Date.ToString("dddd") + ", " + p_Date.ToShortTimeString()); } if (p_Date >= DateTime.Today.AddYears(-1)) { return new HtmlString(p_Date.ToString("dd MMM") + ", " + p_Date.ToShortTimeString()); } if (p_Date == DateTime.MinValue) { return new HtmlString(""); } return new HtmlString(p_Date.ToString("dd MMM yy") + ", " + p_Date.ToShortTimeString()); }
/// <summary> /// Clears all items from the database where their PublishDate is before the date provided. /// </summary> /// <param name="date"></param> public void ClearItemsBeforeDate(DateTime date) { try { using (SqliteConnection connection = new SqliteConnection(ItemsConnectionString)) { connection.Open(); using (SqliteCommand command = new SqliteCommand(connection)) { string sql = @"DELETE FROM items WHERE DATETIME(publishdate) <= DATETIME(@date)"; command.CommandText = sql; SqliteParameter parameter = new SqliteParameter("@date", DbType.String); parameter.Value = date.ToString("yyyy-MM-dd HH:mm:ss"); command.Parameters.Add(parameter); int rows = command.ExecuteNonQuery(); Logger.Info("ClearItemsBeforeDate before {0} cleared {1} rows.", date.ToString("yyyy-MM-dd HH:mm:ss"), rows); } } } catch (SqliteException e) { Logger.Warn("SqliteException occured while clearing items before {0}: \n{1}", date, e); } }
public static string DateDiff(DateTime dt) { TimeSpan span = (TimeSpan) (DateTime.Now - dt); if ((((dt.Year == DateTime.Now.Year) && (dt.Day == DateTime.Now.Day)) && ((dt.Month == DateTime.Now.Month) && (dt.Hour == DateTime.Now.Hour))) && (((span.Seconds < 60) && (span.Hours == 0)) && (span.Minutes == 0))) { return "刚刚"; } if ((((dt.Year == DateTime.Now.Year) && (dt.Day == DateTime.Now.Day)) && ((dt.Month == DateTime.Now.Month) && (span.Minutes < 60))) && (span.Hours == 0)) { return (span.Minutes + "分钟前"); } if (((dt.Year == DateTime.Now.Year) && (dt.Day == DateTime.Now.Day)) && ((dt.Month == DateTime.Now.Month) && (span.Hours <= 2))) { return (span.Hours + "小时前"); } if (dt.AddDays(1.0).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")) { return ("昨天" + dt.ToString("HH:mm")); } if (((dt.Year == DateTime.Now.Year) && (dt.Day == DateTime.Now.Day)) && ((dt.Month == DateTime.Now.Month) && (span.Hours > 2))) { return ("今天" + dt.ToString("HH:mm")); } return dt.ToString("yyyy-MM-dd HH:mm:ss"); }
private void Btn_workTimeReg_Click(object sender, RoutedEventArgs e) { System.DateTime?sdt = sDateTime.SelectedDateTime; System.DateTime?edt = eDateTime.SelectedDateTime; if (sdt == null || edt == null) { //MessageBox.Show("날짜가 입력되지 않았습니다."); _vm.ShowError("날짜가 입력되지 않았습니다."); return; } String workDate = sdt?.ToString("yyyyMMdd"); String _sDateTime = sdt?.ToString("yyyyMMdd") + sdt?.TimeOfDay.ToString().Replace(":", ""); String _eDateTime = edt?.ToString("yyyyMMdd") + edt?.TimeOfDay.ToString().Replace(":", ""); int sTime = Int32.Parse(sdt?.TimeOfDay.ToString().Replace(":", "")); int eTime = Int32.Parse(edt?.TimeOfDay.ToString().Replace(":", "")); //등록시간 체크 if (!(sdt?.ToString("yyyyMMdd")).Equals(edt?.ToString("yyyyMMdd")) && eTime != 0 ) { //MessageBox.Show("동일한 날짜만 넣을 수 있습니다."); _vm.ShowError("동일한 날짜만 넣을 수 있습니다."); return; } if (double.Parse(_sDateTime) >= double.Parse(_eDateTime)) { //MessageBox.Show("출근시간이 퇴근시간보다 클 수 없습니다."); _vm.ShowError("출근시간이 퇴근시간보다 클 수 없습니다."); return; } //데이터베이스 등록처리 regWorkData(workDate, _sDateTime, _eDateTime, sTime, eTime); }
void DoMyWindow(int windowID) { if (CloseButton.Contains(Event.current.mousePosition)) { if (GUI.Button(new Rect(CloseButton), "X", com.Skin[GameControl.control.GUIID].customStyles[0])) { appman.SelectedApp = "Calendar v2"; } GUI.backgroundColor = com.colors[Customize.cust.ButtonColorInt]; GUI.contentColor = com.colors[Customize.cust.FontColorInt]; } else { GUI.backgroundColor = com.colors[Customize.cust.ButtonColorInt]; GUI.contentColor = com.colors[Customize.cust.FontColorInt]; GUI.Button(new Rect(CloseButton), "X", com.Skin[GameControl.control.GUIID].customStyles[1]); } GUI.DragWindow(new Rect(2, 2, CloseButton.x - 4, 21)); GUI.Box(new Rect(2, 2, CloseButton.x - 3, 21), "" + "Calendar v2"); int rows = 0; float x = 0; float y = 0; day = 0; //GUI.Label(new Rect(2, windowRect.height - 160, 200, 21), SelectedTime.DayName); //if(GUI.Button(new Rect(100, windowRect.height - 160, 200, 21), "Reset")) //{ // DateReset(); //} if (Menu == "Dates") { GUI.Label(new Rect(DateString), SelectedTime.Day + " " + date.ToString("MMMM") + " " + date.Year + " " + SelectedTime.DayName); if (DateString.Contains(Event.current.mousePosition)) { if (Input.GetMouseButtonDown(0)) { Menu = "Months"; } } //if (GUI.Button(new Rect(windowRect.width - 44, windowRect.height - 60, 22, 21), "<M")) //{ // SwitchMonth(-1); //} //if (GUI.Button(new Rect(windowRect.width - 21, windowRect.height - 60, 18, 21), ">")) //{ // SwitchMonth(1); //} GUI.Box(new Rect(2, windowRect.height - 155, 21, 21), "S"); GUI.Box(new Rect(24, windowRect.height - 155, 21, 21), "M"); GUI.Box(new Rect(46, windowRect.height - 155, 21, 21), "T"); GUI.Box(new Rect(68, windowRect.height - 155, 21, 21), "W"); GUI.Box(new Rect(90, windowRect.height - 155, 21, 21), "T"); GUI.Box(new Rect(112, windowRect.height - 155, 21, 21), "F"); GUI.Box(new Rect(134, windowRect.height - 155, 21, 21), "S"); for (int i = 0; i < Days.Count; i++) { if (Days[i] != "") { day = day + 1; if (GUI.Button(new Rect(2 + x, windowRect.height - 154 + y + 21, 21, 21), Days[i])) { SelectedTime.Day = day; System.DateTime dt = new System.DateTime(date.Year, date.Month, SelectedTime.Day); SelectedTime.DayName = "" + dt.DayOfWeek; if (DatePicker == true) { if (EventStart == true) { eventview.Reminder.EventStart.Day = SelectedTime.Day; eventview.Reminder.EventStart.Month = date.Month; eventview.Reminder.EventStart.Year = date.Year; } else { eventview.Reminder.EventEnd.Day = SelectedTime.Day; eventview.Reminder.EventEnd.Month = date.Month; eventview.Reminder.EventEnd.Year = date.Year; } appman.SelectedApp = "Calendar v2"; } } } rows++; x += 21 + 1; if (rows == 7) { rows = 0; x = 0; y += 21 + 1; } } } if (Menu == "Months") { GUI.Label(new Rect(windowRect.width / 2 - 14, windowRect.height - 165, 200, 22), "" + date.Year); //GUI.Label(new Rect(windowRect.width / 2, windowRect.height - 165, 200, 22), "|"); if (GUI.Button(new Rect(windowRect.width / 2 - 35, windowRect.height - 165, 21, 21), "<")) { SwitchYear(-1); } if (GUI.Button(new Rect(windowRect.width / 2 + 20, windowRect.height - 165, 21, 21), ">")) { SwitchYear(1); } if (GUI.Button(new Rect(windowRect.width - 42, windowRect.height - 165, 40, 21), "RSET")) { Days.RemoveRange(0, Days.Count); CurrentTimeUpdate(); Menu = "Dates"; } //if (GUI.Button(new Rect(windowRect.width - 66, windowRect.height - 120, 22, 21), "DAT")) //{ // Menu = "Dates"; //} for (int i = 1; i < 13; i++) { if (GUI.Button(new Rect(2 + x, windowRect.height - 154 + y + 21, 42, 42), "" + Months[i])) { SelectedTime.Month = i; SelectedTime.Day = 1; date = new System.DateTime(date.Year, SelectedTime.Month, SelectedTime.Day); SelectedTime.DayName = "" + date.DayOfWeek; Days.RemoveRange(0, Days.Count); UpdateGrid(); Menu = "Dates"; } rows++; x += 42 + 1; if (rows == 4) { rows = 0; x = 0; y += 42 + 1; } } } if (Menu == "Years") { GUI.Label(new Rect(2, windowRect.height - 178, 200, 22), "" + date.Year); if (GUI.Button(new Rect(windowRect.width - 66, windowRect.height - 120, 22, 21), "DAT")) { Menu = "Dates"; } for (int i = 1; i < 10; i++) { if (i < 4) { if (GUI.Button(new Rect(2 + x, windowRect.height - 122 + y + 21, 32, 32), "" + i)) { SelectedYear = i; Menu = "Month"; } } rows++; x += 32 + 1; if (rows == 3) { rows = 0; x = 0; y += 32 + 1; } } } }
public string GetDateOfBirth() { System.DateTime dateOfBirth = System.DateTime.Parse(_userData.dateOfBirth); return(dateOfBirth.ToString("MMMM dd, yyyy")); }
public void Update() { Debug.Log(expiryTime.ToString()); if (System.DateTime.Now > expiryTime) { //OnTimer (); this.ScheduleTimer(); } Debug.Log(PlayerPrefs.GetFloat("TimeOnExit")); //Debug.Log(savedSeconds); Debug.Log(seconds); //PlayerPrefs.SetInt ("TimeOnExit", savedSeconds); //Debug.Log(milliseconds); if (PlayerPrefs.GetInt("lives") <= 0) { //count down in seconds //PlayerPrefs.SetFloat("TimeOnExit",60); milliseconds += Time.deltaTime; if (resetTimer) { ResetTimer(); } if (milliseconds >= 1.0f) { milliseconds -= 1.0f; if ((seconds > 0) || (minutes > 0)) { seconds--; if (seconds < 0) { seconds = 59; minutes--; } } else { //add code to flag and stop endless loop //resetTimer = true; resetTimer = allowTimerRestart; } } if (PlayerPrefs.GetInt("lives") == 3) { //allowTimerRestart = true; ScoreManager.instance.hp = 10; allowTimerRestart = true; minutes = defaultStartMinutes; // } else { allowTimerRestart = false; } if (seconds != savedSeconds) { //Show Current Time timer.text = string.Format("Time:{0}:{1:D2}", minutes, seconds); savedSeconds = seconds; } if (seconds <= 0 && minutes <= 0) { PlayerPrefs.SetFloat("TimeOnExit", 0); PlayerPrefs.SetInt("lives", 3); ScoreManager.instance.hp = 10; savedSeconds = 60; //minutes = 1; //seconds = 60; } } }
public void getStation() { SoundManager.Instance().PlaySfx(SoundManager.Instance().buyTi); bool station = MainSingleTon.Instance.position_house; int cTitanium = MainSingleTon.Instance.cTitanium; string Query = ""; if (station) { return; } if (cTitanium >= 2500) { System.DateTime getTime = System.DateTime.Now; Query = "UPDATE managePlanetTable SET position_house = " + 1 + ", titaniumTouchT = \"" + getTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE rowid = " + MainSingleTon.Instance.rowid; SQLManager.GetComponent <MainSceneSQL>().UpdateQuery(Query); MainSingleTon.Instance.cTitanium -= 2500; Query = "UPDATE userTable SET cTitanium = " + MainSingleTon.Instance.cTitanium; SQLManager.GetComponent <MainSceneSQL>().UpdateQuery(Query); } else { activeLake(); } setBuildingPanal(); setStoreText(); }
public void getEnergy() { System.DateTime touchTime = System.DateTime.Now; string Query = ""; if (planetTouchT == "0") { Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("생산시작"); return; } if (lFood == 0 && lTitanium == 0) { Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); return; } switch (size) { case 1: maxStoreE = 200; break; case 2: maxStoreE = 400; break; case 3: maxStoreE = 800; break; case 4: maxStoreE = 1600; break; default: maxStoreE = 200; break; } System.DateTime preT = System.DateTime.ParseExact(planetTouchT, "yyyy-MM-dd HH:mm:ss", null); System.TimeSpan deff = touchTime - preT; int defTime = System.Convert.ToInt32(deff.TotalSeconds); int calculateEnergy = System.Convert.ToInt32(defTime * getCountE); //이후시간, 이전시간 = 1, 같은경우 = 0, 이전,이후 = -1 int comp = System.DateTime.Compare(touchTime, preT); if (comp == 1) { string tempQuery1 = ""; string tempQuery2 = ""; switch (color) { case 1: //b if (cBE >= maxE) { cBE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cBE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cBE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cBE > maxE) { cBE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cBE = " + cBE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; case 2: //r if (cRE >= maxE) { cRE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cRE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cRE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cRE > maxE) { cRE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cRE = " + cRE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; case 3: //y if (cYE >= maxE) { cYE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cYE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cYE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cYE > maxE) { cYE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cYE = " + cYE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; case 4: //v if (cVE >= maxE) { cVE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cVE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cVE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cVE > maxE) { cVE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cVE = " + cVE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; case 5: //g if (cGE >= maxE) { cGE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cGE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cGE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cGE > maxE) { cGE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cGE = " + cGE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; case 6: //o if (cOE >= maxE) { cOE = maxE; Query = "UPDATE managePlanetTable SET planetTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("MAX"); return; } if (calculateEnergy <= maxStoreE) { cOE += calculateEnergy; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + calculateEnergy.ToString()); } else { cOE += maxStoreE; tempTex = Instantiate(getEnergyText, getEspawn.transform.localPosition, Quaternion.identity) as GameObject; tempTex.transform.SetParent(GameObject.Find("UI").transform, false); tempTex.GetComponent <getEnergyTextScript>().setText("+" + maxStoreE.ToString()); } if (cOE > maxE) { cOE = maxE; } planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); tempQuery1 = "UPDATE userTable SET cOE = " + cOE; tempQuery2 = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; break; default: return; } Debug.Log(tempQuery1); Debug.Log(tempQuery2); SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(tempQuery1); SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(tempQuery2); return; } else if (comp == 0) { return; } else { planetTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); Query = "UPDATE managePlanetTable SET planetTouchT = \"" + planetTouchT + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); } }
void OnEnable() { EquimentList = GameManager.Instance.GetEquimentShopData(); if (EquimentList == null) { EquimentList = new List <CGameEquiment>(); } if (CheckIsTimer()) { PlayerPrefs.SetString("NowTime", EndData.ToString()); EquimentList.Clear(); for (int nIndex = 0; nIndex < nShopMaxLength; nIndex++) { ShopList [nIndex].SetUp(nIndex); } for (int nIndex = 0; nIndex < playerData.GetShopMaxCount(); nIndex++) { CGameEquiment cGameEquiment = GetEquiment(); ShopList[nIndex].GetEquiment(this, inventory, showPanel, cGameEquiment); EquimentList.Add(cGameEquiment); } FirstCheck(); StartCoroutine(Timer(nInitTime_Min, nInitTime_Sec)); } else { if (EquimentList.Count != 0) { if (playerData.GetShopMaxCount() != EquimentList.Count) { int nCount = playerData.GetShopMaxCount() - EquimentList.Count; int nEquipmentCount = EquimentList.Count; for (int nIndex = 0; nIndex < EquimentList.Count; nIndex++) { CGameEquiment cGameEquiment = EquimentList [nIndex]; ShopList [nIndex].GetEquiment(this, inventory, showPanel, cGameEquiment); } for (int nIndex = nEquipmentCount; nIndex < nEquipmentCount + nCount; nIndex++) { CGameEquiment cGameEquiment = GetEquiment(); ShopList[nIndex].GetEquiment(this, inventory, showPanel, cGameEquiment); EquimentList.Add(cGameEquiment); } FirstCheck(); } else { for (int nIndex = 0; nIndex < EquimentList.Count; nIndex++) { CGameEquiment cGameEquiment = EquimentList [nIndex]; ShopList [nIndex].GetEquiment(this, inventory, showPanel, cGameEquiment); } FirstCheck(); } } //완전 처음 일 경우 else { for (int nIndex = 0; nIndex < playerData.GetShopMaxCount(); nIndex++) { CGameEquiment cGameEquiment = GetEquiment(); ShopList[nIndex].GetEquiment(this, inventory, showPanel, cGameEquiment); EquimentList.Add(cGameEquiment); } FirstCheck(); } if (PlayerPrefs.HasKey("ShopCloseTime")) { strCloseTime = PlayerPrefs.GetString("ShopCloseTime"); CloseEndData = System.Convert.ToDateTime(strCloseTime); StartDate = System.DateTime.Now; timeCal = StartDate - CloseEndData; int nStartTime = StartDate.Hour * 3600 + StartDate.Minute * 60 + StartDate.Second; int nEndTime = CloseEndData.Hour * 3600 + CloseEndData.Minute * 60 + CloseEndData.Second; int nCheck = Mathf.Abs(nEndTime - nStartTime); int nPassedTime_Min = (int)timeCal.TotalMinutes; //전체 분s int nPassedTime_Sec = (int)timeCal.TotalSeconds % 60; //전채 초에서 나머지 //60분이 지나지 않았다면 저장된 분에서 지나간 분 만큼 뺀 시간을 시작한다 if (nPassedTime_Min < 59) { int ResultTime_Min = GameManager.Instance.GetPlayer().changeStats.nShopMinutes - nPassedTime_Min; if (ResultTime_Min < 0) { ResultTime_Min = -ResultTime_Min; } int ResultTime_Sec = (int)GameManager.Instance.GetPlayer().changeStats.fShopSecond - nPassedTime_Sec; if (ResultTime_Sec < 0) { ResultTime_Sec = -ResultTime_Sec; } StartCoroutine(Timer(ResultTime_Min, (int)ResultTime_Sec)); } } else { CloseEndData = System.DateTime.Now; PlayerPrefs.SetString("BossRegenTime", EndData.ToString()); StartCoroutine(Timer(nInitTime_Min, nInitTime_Sec)); } } GameManager.Instance.SaveShopList(EquimentList); }
public string namePrefix = "Capture_"; // Before the timestamp // Example "Gametitle_" private string GetTimestamp() { System.DateTime dateTime = System.DateTime.Now; return(dateTime.ToString(Timestamp)); }
public void InsertUserId(string userId) { getAllData(); NCMBObject userIdClass = new NCMBObject("dataStore"); System.DateTime now = System.DateTime.Now; userIdClass["userId"] = userId; userIdClass["loginDate"] = now.ToString(); userIdClass["platform"] = SystemInfo.operatingSystem; userIdClass["appVer"] = Application.version; userIdClass["kuniLv"] = kuniLv; userIdClass["kuniExp"] = kuniExp; userIdClass["myDaimyo"] = myDaimyo; userIdClass["addJinkei1"] = addJinkei1; userIdClass["addJinkei2"] = addJinkei2; userIdClass["addJinkei3"] = addJinkei3; userIdClass["addJinkei4"] = addJinkei4; /**Data Store**/ //basic userIdClass["seiryoku"] = seiryoku; userIdClass["money"] = money; userIdClass["busyoDama"] = busyoDama; userIdClass["syogunDaimyoId"] = syogunDaimyoId; userIdClass["doumei"] = doumei; userIdClass["questSpecialFlgId"] = questSpecialFlgId; userIdClass["questSpecialReceivedFlgId"] = questSpecialReceivedFlgId; userIdClass["questSpecialCountReceivedFlg"] = questSpecialCountReceivedFlg; userIdClass["yearSeason"] = yearSeason; userIdClass["movieCount"] = movieCount; //busyo userIdClass["gacyaDaimyoHst"] = gacyaDaimyoHst; userIdClass["myBusyoList"] = myBusyoList; userIdClass["lvList"] = lvList; userIdClass["heiList"] = heiList; userIdClass["senpouLvList"] = senpouLvList; userIdClass["sakuLvList"] = sakuLvList; userIdClass["kahouList"] = kahouList; userIdClass["addLvList"] = addLvList; userIdClass["gokuiList"] = gokuiList; userIdClass["kanniList"] = kanniList; //kaho userIdClass["availableBugu"] = availableBugu; userIdClass["availableKabuto"] = availableKabuto; userIdClass["availableGusoku"] = availableGusoku; userIdClass["availableMeiba"] = availableMeiba; userIdClass["availableCyadougu"] = availableCyadougu; userIdClass["availableHeihousyo"] = availableHeihousyo; userIdClass["availableChishikisyo"] = availableChishikisyo; //item userIdClass["myKanni"] = myKanni; userIdClass["kanjyo"] = kanjyo; userIdClass["cyouheiYR"] = cyouheiYR; userIdClass["cyouheiKB"] = cyouheiKB; userIdClass["cyouheiTP"] = cyouheiTP; userIdClass["cyouheiYM"] = cyouheiYM; userIdClass["hidensyoGe"] = hidensyoGe; userIdClass["hidensyoCyu"] = hidensyoCyu; userIdClass["hidensyoJyo"] = hidensyoJyo; userIdClass["shinobiGe"] = shinobiGe; userIdClass["shinobiCyu"] = shinobiCyu; userIdClass["shinobiJyo"] = shinobiJyo; userIdClass["kengouItem"] = kengouItem; userIdClass["gokuiItem"] = gokuiItem; userIdClass["nanbanItem"] = nanbanItem; userIdClass["transferTP"] = transferTP; userIdClass["transferKB"] = transferKB; userIdClass["meisei"] = meisei; userIdClass["shiro"] = shiro; userIdClass["koueki"] = koueki; userIdClass["cyoutei"] = cyoutei; //zukan userIdClass["zukanBusyoHst"] = zukanBusyoHst; userIdClass["zukanBuguHst"] = zukanBuguHst; userIdClass["zukanGusokuHst"] = zukanGusokuHst; userIdClass["zukanKabutoHst"] = zukanKabutoHst; userIdClass["zukanMeibaHst"] = zukanMeibaHst; userIdClass["zukanCyadouguHst"] = zukanCyadouguHst; userIdClass["zukanChishikisyoHst"] = zukanChishikisyoHst; userIdClass["zukanHeihousyoHst"] = zukanHeihousyoHst; userIdClass["gameClearDaimyo"] = gameClearDaimyo; userIdClass["gameClearDaimyoHard"] = gameClearDaimyoHard; //naisei userIdClass["naiseiKuniList"] = naiseiKuniList; userIdClass["naiseiList"] = naiseiList; userIdClass["naiseiShiroList"] = naiseiShiroList; userIdClass.SaveAsync(); RegisteredFlg = true; }
public void SetTime(System.DateTime datetime) { TimeText.text = datetime.ToString("yyyy-MM-dd"); }
void DrawMenuLoadSave(bool load) { if (load) { MenuSystem.BeginMenu("Load"); } else { MenuSystem.BeginMenu("Save"); } for (int i = 0; i < 5; i++) { System.DateTime fileDateTime = WorldManagerUnity.GetWorldFileInfo(i); if (fileDateTime != System.DateTime.MinValue) { string prefix; if (load) { prefix = "Load World "; } else { prefix = "Overwrite World"; } MenuSystem.Button(prefix + (i + 1).ToString() + " [ " + fileDateTime.ToString() + " ]", delegate() { if (load) { gameManagerUnity.worldManagerUnity.LoadWorld(i); state = MainMenuState.NORMAL; } else { gameManagerUnity.worldManagerUnity.SaveWorld(i); state = MainMenuState.NORMAL; } } ); } else { MenuSystem.Button("-- Empty Slot --", delegate() { if (load == false) { gameManagerUnity.worldManagerUnity.SaveWorld(i); state = MainMenuState.NORMAL; } } ); } } MenuSystem.LastButton("Return", delegate() { state = MainMenuState.NORMAL; } ); MenuSystem.EndMenu(); }
void Awake() { try { NetworkTransport.Init(); serverConfig = new ConnectionConfig(); serverChannelId = serverConfig.AddChannel(QosType.StateUpdate); // QosType.UnreliableFragmented serverConfig.MaxSentMessageQueueSize = 2048; // 128 by default // start data server serverTopology = new HostTopology(serverConfig, maxConnections); serverHostId = NetworkTransport.AddHost(serverTopology, listenOnPort); if (serverHostId < 0) { throw new UnityException("AddHost failed for port " + listenOnPort); } // add broadcast host if (broadcastPort > 0) { broadcastHostId = NetworkTransport.AddHost(serverTopology, 0); if (broadcastHostId < 0) { throw new UnityException("AddHost failed for broadcast discovery"); } } // set broadcast data string sBroadcastData = string.Empty; #if !UNITY_WSA try { string strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; string sHostInfo = "Host: " + strHostName; for (int i = 0; i < addr.Length; i++) { if (addr[i].AddressFamily == AddressFamily.InterNetwork) { sHostInfo += ", IP: " + addr[i].ToString(); sBroadcastData = "KinectDataServer:" + addr[i].ToString() + ":" + listenOnPort; break; } } sHostInfo += ", Port: " + listenOnPort; Debug.Log(sHostInfo); if (serverStatusText) { serverStatusText.text = sHostInfo; } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n\n" + ex.StackTrace); if (serverStatusText) { serverStatusText.text = "Use 'ipconfig' to see the host IP; Port: " + listenOnPort; } } #else sBroadcastData = "KinectDataServer:" + "127.0.0.1" + ":" + listenOnPort; #endif // start broadcast discovery if (broadcastPort > 0) { broadcastOutBuffer = System.Text.Encoding.UTF8.GetBytes(sBroadcastData); byte error = 0; if (!NetworkTransport.StartBroadcastDiscovery(broadcastHostId, broadcastPort, 8888, 1, 0, broadcastOutBuffer, broadcastOutBuffer.Length, 2000, out error)) { throw new UnityException("Start broadcast discovery failed: " + (NetworkError)error); } } liRelTime = 0; fCurrentTime = Time.time; System.DateTime dtNow = System.DateTime.UtcNow; Debug.Log("Kinect data server started at " + dtNow.ToString() + " - " + dtNow.Ticks); if (connStatusText) { connStatusText.text = "Server running: 0 connection(s)"; } } catch (System.Exception ex) { Debug.LogError(ex.Message + "\n" + ex.StackTrace); if (connStatusText) { connStatusText.text = ex.Message; } } }
public void makeInitData() { //Check if (!PlayerPrefs.HasKey("lasttime")) { initDataInt = PlayerPrefs.GetInt("initDataInt"); if (initDataInt == 0) { /*******************************/ /***** MainStageController *****/ /*******************************/ //Basic status System.DateTime now = System.DateTime.Now; PlayerPrefs.SetString("lasttime", now.ToString()); PlayerPrefs.SetInt("kuniLv", 1); PlayerPrefs.SetInt("kuniExp", 0); PlayerPrefs.SetInt("money", 10000); PlayerPrefs.SetInt("busyoDama", 0); PlayerPrefs.SetInt("hyourouMax", 100); PlayerPrefs.SetInt("hyourou", 100); PlayerPrefs.SetInt("myBusyoQty", 1); PlayerPrefs.SetInt("syogunDaimyoId", 14); //Busyo int myDaimyo = 1; //Oda Nobunaga PlayerPrefs.SetInt("myDaimyo", myDaimyo); PlayerPrefs.SetInt("myDaimyoBusyo", 19); //Open Kuni PlayerPrefs.SetString("openKuni", "1,2,3,4"); PlayerPrefs.SetString("kuni1", "1,2,3,4,5,6,7,8,9,10"); //Owari PlayerPrefs.SetString("clearedKuni", "1"); //Seiryoku PlayerPrefs.SetString("seiryoku", "1,2,3,4,5,6,7,8,3,4,9,10,12,11,13,14,15,16,3,17,18,17,19,8,19,19,20,21,22,23,24,25,26,27,28,29,30,31,31,32,33,34,35,35,36,37,38,38,38,38,31,31,31,39,40,41,41,41,41,42,43,44,45,45,46"); //Year & Season string newYearSeason = "1560,1"; PlayerPrefs.SetString("yearSeason", newYearSeason); /*******************************/ /***** JinkeiScene *****/ /*******************************/ PlayerPrefs.SetInt("jinkei", 1); PlayerPrefs.SetString("myBusyo", "19"); PlayerPrefs.SetInt("jinkeiLimit", 3); PlayerPrefs.SetInt("map12", 19); PlayerPrefs.SetInt("1map12", 19); PlayerPrefs.SetInt("jinkeiBusyoQty", 1); PlayerPrefs.SetInt("jinkeiAveLv", 1); PlayerPrefs.SetInt("jinkeiAveChLv", 1); PlayerPrefs.SetInt("jinkeiHeiryoku", 1100); PlayerPrefs.SetInt("soudaisyo1", 19); /*******************************/ /***** Busyo Scene *****/ /*******************************/ PlayerPrefs.SetInt("stockLimit", 10); PlayerPrefs.SetInt("19", 1); PlayerPrefs.SetString("hei19", "TP:1:1:1"); PlayerPrefs.SetInt("senpou19", 1); PlayerPrefs.SetInt("saku19", 1); PlayerPrefs.SetString("kahou19", "0,0,0,0,0,0,0,0"); PlayerPrefs.SetInt("exp19", 0); /*******************************/ /***** Cyouhei Scene *****/ /*******************************/ PlayerPrefs.SetString("cyouheiYR", "0,0,0"); PlayerPrefs.SetString("cyouheiKB", "0,0,0"); PlayerPrefs.SetString("cyouheiTP", "0,0,0"); PlayerPrefs.SetString("cyouheiYM", "0,0,0"); PlayerPrefs.SetString("kanjyo", "0,0,0"); /*******************************/ /***** Naisei Scene *****/ /*******************************/ PlayerPrefs.SetString("naisei1", "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); PlayerPrefs.SetString("naisei2", "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); PlayerPrefs.SetString("naisei3", "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); PlayerPrefs.SetString("naisei4", "1,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0,0:0"); PlayerPrefs.SetInt("transferTP", 0); PlayerPrefs.SetInt("transferKB", 0); PlayerPrefs.SetInt("transferSNB", 0); /*******************************/ /***** Item *****/ /*******************************/ PlayerPrefs.SetString("gokuiItem", "0,0,0,0,0"); PlayerPrefs.SetString("kengouItem", "0,0,0,0,0,0,0,0,0,0"); PlayerPrefs.SetString("nanbanItem", "0,0,0"); PlayerPrefs.SetString("cyoutei", "0,0,0"); PlayerPrefs.SetString("koueki", "0,0,0"); /*******************************/ /***** Gaikou Value *****/ /*******************************/ Gaikou gaikou = new Gaikou(); for (int l = 2; l < 47; l++) { int value = gaikou.getGaikouValue(myDaimyo, l); string temp = "gaikou" + l.ToString(); PlayerPrefs.SetInt(temp, value); } /*******************************/ /***** Doumei *****/ /*******************************/ PlayerPrefs.SetString("doumei2", "9"); PlayerPrefs.SetString("doumei9", "2"); PlayerPrefs.SetString("doumei3", "8,19"); PlayerPrefs.SetString("doumei8", "3,19,26"); PlayerPrefs.SetString("doumei19", "3,8,26"); PlayerPrefs.SetString("doumei26", "8,19"); PlayerPrefs.SetString("doumei38", "36,37,39"); PlayerPrefs.SetString("doumei36", "38"); PlayerPrefs.SetString("doumei37", "38"); PlayerPrefs.SetString("doumei39", "38"); PlayerPrefs.SetString("doumei5", "6"); PlayerPrefs.SetString("doumei6", "5"); /*******************************/ /***** Tutorial *****/ /*******************************/ PlayerPrefs.SetInt("tutorialId", 1); /*******************************/ /***** Init Common Process *****/ /*******************************/ //Change initDataFlg PlayerPrefs.SetBool("initDataFlg", true); PlayerPrefs.SetInt("initDataInt", 1); PlayerPrefs.Flush(); } } }
public override void SetTime(System.DateTime time) { text.text = time.ToString(timeFormat); }
public void BossInviteMentLoadTime() { //저장된 초대장 시간이 있다면 if (PlayerPrefs.HasKey("BossInvitementSaveTime")) { strTime = PlayerPrefs.GetString("BossInvitementSaveTime"); EndData = System.Convert.ToDateTime(strTime); Debug.Log("BossInvitement Time Load : " + EndData.ToString()); } //없으면 (맨 처음 최초 실행때만 호출) else { PlayerPrefs.SetString("BossInvitementSaveTime", EndData.ToString()); Debug.Log("BossInvitement init Time : " + EndData.ToString()); inviteMentCount_Text.text = nInviteMentCurCount.ToString() + " / " + nInviteMentMaxCount.ToString(); inviteMentTimer_Text.enabled = false; curMin = 19; fCurSec = 59f; return; } StartedTime = System.DateTime.Now; timeCal = StartedTime - EndData; int nStartTime = StartedTime.Hour * 3600 + StartedTime.Minute * 60 + StartedTime.Second; int nEndTime = EndData.Hour * 3600 + EndData.Minute * 60 + EndData.Second; int nCheck = Mathf.Abs(nEndTime - nStartTime); //하루가 지나거나 100분이 지나거나 현재 초대장이 가득 찼으면 if (timeCal.Days != 0 || nCheck >= 4500 || nInviteMentCurCount == nInviteMentMaxCount) { //초대장 갯수 풀로 할것 nInviteMentCurCount = nInviteMentMaxCount; isTimeOn_BossInviteMentTimer = false; inviteMentTimer_Text.enabled = false; inviteMentCount_Text.text = nInviteMentCurCount.ToString() + " / " + nInviteMentMaxCount.ToString(); } // else { //StartTimer; //6000s //100m //1h + 40m int nPassedTime_Min = (int)timeCal.TotalMinutes; int nPassedTime_Sec = (int)timeCal.Seconds % 60; //15분이 지나지 않았다면 저장된 분에서 지나간 분 만큼 뺀 시간을 시작한다 if (nPassedTime_Min < 15) { int ResultTime_Min = GameManager.Instance.cBossPanelListInfo [0].nBossInviteMentCurMin - nPassedTime_Min; int ResultTime_Sec = (int)GameManager.Instance.cBossPanelListInfo [0].fBossInviteMentCurSec - nPassedTime_Sec; if (ResultTime_Sec < 0) { ResultTime_Sec = -ResultTime_Sec; } StartCoroutine(Timer(ResultTime_Min, ResultTime_Sec)); } /* * else if (nPassedTime_Min < 40) * { * nInviteMentCurCount += 1; * nPassedTime_Min = (int)nPassedTime_Min - 20; * nPassedTime_Sec = (int)((nPassedTime_Sec - 1200) % 60); * StartCoroutine (Timer (nInitTime_Min - nPassedTime_Min, nInitTime_sec - nPassedTime_Sec)); * } * else if (nPassedTime_Min < 60) * { * nInviteMentCurCount += 2; * nPassedTime_Min = (int)nPassedTime_Min - 40; * nPassedTime_Sec = (int)((nPassedTime_Sec - 2400) % 60); * StartCoroutine (Timer (nInitTime_Min - nPassedTime_Min, nInitTime_sec - nPassedTime_Sec)); * } * else if (nPassedTime_Min < 80) * { * nInviteMentCurCount += 3; * nPassedTime_Min = (int)nPassedTime_Min - 60; * nPassedTime_Sec = (int)((nPassedTime_Sec - 3600) % 60); * StartCoroutine (Timer (nInitTime_Min - nPassedTime_Min, nInitTime_sec -nPassedTime_Sec)); * } * else if (nPassedTime_Min < 100) * { * nInviteMentCurCount += 4; * nPassedTime_Min = (int)nPassedTime_Min - 80; * nPassedTime_Sec = (int)((nPassedTime_Sec - 4800) % 60); * StartCoroutine (Timer (nInitTime_Min - nPassedTime_Min, nInitTime_sec - nPassedTime_Sec)); * } */ inviteMentTimer_Text.enabled = true; } }
/// <summary> /// A DateTime extension method that converts this object to a year month string. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>The given data converted to a string.</returns> public static string ToYearMonthString(this System.DateTime @this) { return(@this.ToString("y", DateTimeFormatInfo.CurrentInfo)); }
public void UpdateUserId(string userId) { NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>("dataStore"); query.WhereEqualTo("userId", userId); getAllData(); query.FindAsync((List <NCMBObject> objList, NCMBException e) => { if (e == null) { if (objList.Count == 0) //never registered { InsertUserId(userId); } else //registered { string loginDate = System.Convert.ToString(objList[0]["loginDate"]); System.DateTime now = System.DateTime.Now; if (now.ToString() != loginDate) { objList[0]["loginDate"] = now.ToString(); objList[0]["platform"] = SystemInfo.operatingSystem; objList[0]["appVer"] = Application.version; objList[0]["kuniLv"] = kuniLv; objList[0]["kuniExp"] = kuniExp; objList[0]["myDaimyo"] = myDaimyo; objList[0]["addJinkei1"] = addJinkei1; objList[0]["addJinkei2"] = addJinkei2; objList[0]["addJinkei3"] = addJinkei3; objList[0]["addJinkei4"] = addJinkei4; /**Data Store**/ //basic objList[0]["seiryoku"] = seiryoku; objList[0]["money"] = money; objList[0]["busyoDama"] = busyoDama; objList[0]["syogunDaimyoId"] = syogunDaimyoId; objList[0]["doumei"] = doumei; objList[0]["questSpecialFlgId"] = questSpecialFlgId; objList[0]["questSpecialReceivedFlgId"] = questSpecialReceivedFlgId; objList[0]["questSpecialCountReceivedFlg"] = questSpecialCountReceivedFlg; objList[0]["yearSeason"] = yearSeason; objList[0]["movieCount"] = movieCount; //busyo objList[0]["gacyaDaimyoHst"] = gacyaDaimyoHst; objList[0]["myBusyoList"] = myBusyoList; objList[0]["lvList"] = lvList; objList[0]["heiList"] = heiList; objList[0]["senpouLvList"] = senpouLvList; objList[0]["sakuLvList"] = sakuLvList; objList[0]["kahouList"] = kahouList; objList[0]["addLvList"] = addLvList; objList[0]["gokuiList"] = gokuiList; objList[0]["kanniList"] = kanniList; //kaho objList[0]["availableBugu"] = availableBugu; objList[0]["availableKabuto"] = availableKabuto; objList[0]["availableGusoku"] = availableGusoku; objList[0]["availableMeiba"] = availableMeiba; objList[0]["availableCyadougu"] = availableCyadougu; objList[0]["availableHeihousyo"] = availableHeihousyo; objList[0]["availableChishikisyo"] = availableChishikisyo; //item objList[0]["myKanni"] = myKanni; objList[0]["kanjyo"] = kanjyo; objList[0]["cyouheiYR"] = cyouheiYR; objList[0]["cyouheiKB"] = cyouheiKB; objList[0]["cyouheiTP"] = cyouheiTP; objList[0]["cyouheiYM"] = cyouheiYM; objList[0]["hidensyoGe"] = hidensyoGe; objList[0]["hidensyoCyu"] = hidensyoCyu; objList[0]["hidensyoJyo"] = hidensyoJyo; objList[0]["shinobiGe"] = shinobiGe; objList[0]["shinobiCyu"] = shinobiCyu; objList[0]["shinobiJyo"] = shinobiJyo; objList[0]["kengouItem"] = kengouItem; objList[0]["gokuiItem"] = gokuiItem; objList[0]["nanbanItem"] = nanbanItem; objList[0]["transferTP"] = transferTP; objList[0]["transferKB"] = transferKB; objList[0]["meisei"] = meisei; objList[0]["shiro"] = shiro; objList[0]["koueki"] = koueki; objList[0]["cyoutei"] = cyoutei; //zukan objList[0]["zukanBusyoHst"] = zukanBusyoHst; objList[0]["zukanBuguHst"] = zukanBuguHst; objList[0]["zukanGusokuHst"] = zukanGusokuHst; objList[0]["zukanKabutoHst"] = zukanKabutoHst; objList[0]["zukanMeibaHst"] = zukanMeibaHst; objList[0]["zukanCyadouguHst"] = zukanCyadouguHst; objList[0]["zukanChishikisyoHst"] = zukanChishikisyoHst; objList[0]["zukanHeihousyoHst"] = zukanHeihousyoHst; objList[0]["gameClearDaimyo"] = gameClearDaimyo; objList[0]["gameClearDaimyoHard"] = gameClearDaimyoHard; //naisei objList[0]["naiseiKuniList"] = naiseiKuniList; objList[0]["naiseiList"] = naiseiList; objList[0]["naiseiShiroList"] = naiseiShiroList; objList[0].SaveAsync(); RegisteredFlg = true; } } } }); }
/// <summary> /// A DateTime extension method that converts this object to a year month string. /// </summary> /// <param name="this">The @this to act on.</param> /// <param name="culture">The culture.</param> /// <returns>The given data converted to a string.</returns> public static string ToYearMonthString(this System.DateTime @this, CultureInfo culture) { return(@this.ToString("y", culture)); }
public static string Format(this System.DateTime ths) { return(ths.ToString("yyyy-MM-dd HH:mm")); }
public void CapTure() { //获取系统时间并命名相片名 System.DateTime now = System.DateTime.Now; string times = now.ToString(); times = times.Trim(); times = times.Replace("/", "-"); string filename = "Screenshot" + times + ".png"; //判断是否为Android平台 if (Application.platform == RuntimePlatform.Android) { //截取屏幕 int width = Screen.width; int height = Screen.height; Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false); tex.ReadPixels(new Rect(0, 0, width, height), 0, 0, true); //byte[] imagebytes = tex.EncodeToPNG();//转化为png图 //tex.Compress(false);//对屏幕缓存进行压缩 tex.Apply(); //this.image.mainTexture = tex;//对屏幕缓存进行显示(缩略图) Sprite tempSp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0)); //将图转化为ui的贴图 //m_tSprite.GetComponent<Image>().sprite = tempSp;//贴在ui上 this.screenShotImage.sprite = tempSp; //转为字节数组 byte[] bytes = tex.EncodeToPNG(); string destination = "/sdcard/DCIM/ARphoto"; DirectoryInfo mydir = new DirectoryInfo(destination); //判断目录是否存在,不存在则会创建目录 if (!Directory.Exists(destination)) { this.ima.SetActive(true); //Debug.Log("yyyyy"); Directory.CreateDirectory(destination); } //Debug.Log("yyyyy"); //if (mydir.Exists) { // print("文件夹不存在,创建"); // Directory.CreateDirectory(destination); //} //if (!System.IO.Exists(destination)) //{ // System.IO.CreateDirectory(destination); // print("文件夹不存在,创建"); //} string Path_save = destination + "/" + filename; //存图片 System.IO.File.WriteAllBytes(Path_save, bytes); } else { GetCapture(); // 调用客户端的截屏的方法。 } }
public void getTitanium(Vector3 textPos) { System.DateTime touchTime = System.DateTime.Now; string Query = ""; if (titaniumTouchT == "0") { Query = "UPDATE managePlanetTable SET titaniumTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getText, textPos, GameObject.Find("PlanetPosition/DragCamera").transform.rotation) as GameObject; tempTex.GetComponent <getTextScript>().setText("생산시작"); return; } if (cTitanium >= maxTitanium) { cTitanium = maxTitanium; Query = "UPDATE managePlanetTable SET treeTouchT = \"" + touchTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" WHERE User = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); tempTex = Instantiate(getText, textPos, GameObject.Find("PlanetPosition/DragCamera").transform.rotation) as GameObject; tempTex.GetComponent <getTextScript>().setText("MAX"); return; } System.DateTime preT = System.DateTime.ParseExact(titaniumTouchT, "yyyy-MM-dd HH:mm:ss", null); System.TimeSpan deff = touchTime - preT; int defTime = System.Convert.ToInt32(deff.TotalSeconds); int calculateTitanium = System.Convert.ToInt32(defTime * getCountTitanium); //이후시간, 이전시간 = 1, 같은경우 = 0, 이전,이후 = -1 int comp = System.DateTime.Compare(touchTime, preT); if (comp == 1) { if (lTitanium < maxStoreTitanium) { if (calculateTitanium < lTitanium) { cTitanium += calculateTitanium; lTitanium -= calculateTitanium; tempString = calculateTitanium.ToString(); } else // calculateTitanium >=lTitanium { cTitanium += lTitanium; lTitanium = 0; tempString = lTitanium.ToString(); } } else // lFood >= maxStoreFood) { if (calculateTitanium < maxStoreTitanium) { cTitanium += calculateTitanium; lTitanium -= calculateTitanium; tempString = calculateTitanium.ToString(); } else //calculateFood >= maxStoreFood && lFood { cTitanium += maxStoreTitanium; lTitanium -= maxStoreTitanium; tempString = maxStoreTitanium.ToString(); } } if (cTitanium > maxTitanium) { cTitanium = maxTitanium; } if (lTitanium < 0) { lTitanium = 0; } titaniumTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); string tempQuery1 = "UPDATE userTable SET cTitanium = " + cTitanium; string tempQuery2 = "UPDATE managePlanetTable SET titaniumTouchT = \"" + titaniumTouchT + "\", lTitanium = " + lTitanium + " WHERE User = 1 "; Debug.Log(tempQuery1); Debug.Log(tempQuery2); tempTex = Instantiate(getText, textPos, GameObject.Find("PlanetPosition/DragCamera").transform.rotation) as GameObject; tempTex.GetComponent <getTextScript>().setText(tempString); SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(tempQuery1); SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(tempQuery2); setVisibleEnergyBtn(); return; } else if (comp == 0) { return; } else { titaniumTouchT = touchTime.ToString("yyyy-MM-dd HH:mm:ss"); Query = "UPDATE managePlanetTable SET titaniumTouchT = \"" + titaniumTouchT + "\" WHERE user = 1"; SQLManager.GetComponent <PlanetSceneSQL>().UpdateQuery(Query); } }
private string GetTimeString(double seconds) { System.TimeSpan time = System.TimeSpan.FromSeconds(seconds); System.DateTime dateTime = System.DateTime.Today.Add(time); return(dateTime.ToString("mm:ss")); }
bool BackMailUpdateData(uint _msgType, UMessage msg) { EmailData data = new EmailData(); data.emailid = msg.ReadUInt(); data.hasread = msg.ReadByte(); data.sendid = msg.ReadUInt(); data.sendName = msg.ReadString(); uint emailtime = msg.ReadUInt(); data.rewardSorce = (MailFrom_Enum)msg.ReadByte(); data.sorceID = msg.ReadUInt(); data.contestSort = msg.ReaduShort(); data.titleid = msg.ReadUInt(); data.contentID = msg.ReadUInt(); data.specialDiscript1 = msg.ReadString(); data.specialDiscript2 = msg.ReadString(); data.gamekind = msg.ReadByte(); data.emailname = CCsvDataManager.Instance.TipsDataMgr.GetTipsData(data.titleid).TipsText; TipsData tdata = CCsvDataManager.Instance.TipsDataMgr.GetTipsData(data.contentID); byte flag = msg.ReadByte(); if (GameKind.HasFlag(0, flag)) { data.masterReward = msg.ReadSingle(); } if (GameKind.HasFlag(1, flag)) { data.diamondReward = msg.ReadUInt(); } if (GameKind.HasFlag(2, flag)) { data.coinReward = msg.ReadUInt(); } for (int itemindex = 3; itemindex < 6; itemindex++) { if (GameKind.HasFlag(itemindex, flag)) { Item item = new Item(); item.itemid = msg.ReaduShort(); item.itemNumber = msg.ReadByte(); data.emailitems.Add(item); } } if (GameKind.HasFlag(6, flag)) { data.redbag = msg.ReadSingle(); } if (data.rewardSorce == MailFrom_Enum.MailFrom_Contest) { int starttime = 0; int.TryParse(data.specialDiscript1, out starttime); System.DateTime stsdt = GameCommon.ConvertLongToDateTime(starttime); string contenttime = stsdt.ToString("yyyy年MM月dd日HH:mm"); System.DateTime sdt = GameCommon.ConvertLongToDateTime(emailtime); data.emailtime = sdt.ToString("yyyy年MM月dd日HH:mm"); string rewardcontent = ""; if (GameKind.HasFlag(0, flag)) { rewardcontent += "大师分:" + data.masterReward.ToString(); } if (GameKind.HasFlag(6, flag)) { rewardcontent += " 现金红包:" + data.redbag.ToString() + "元"; } if (GameKind.HasFlag(1, flag) || GameKind.HasFlag(2, flag)) { rewardcontent += " 钻石:" + (data.diamondReward + data.coinReward).ToString(); } object[] args = { contenttime, "<color=#FF8C00>" + data.specialDiscript2 + "</color>", data.contestSort, rewardcontent }; string formatcontent = string.Format(tdata.TipsText, args); data.infomation = formatcontent; } else if (data.rewardSorce == MailFrom_Enum.MailFrom_MomentsKick) { object[] args = { data.specialDiscript1 }; string formatcontent = string.Format(tdata.TipsText, args); data.infomation = formatcontent; } else if (data.rewardSorce == MailFrom_Enum.MailFrom_ContestCutCreditScore) { int starttime = 0; int.TryParse(data.specialDiscript1, out starttime); System.DateTime stsdt = GameCommon.ConvertLongToDateTime(starttime); string contenttime = stsdt.ToString("yyyy年MM月dd日HH:mm"); System.DateTime sdt = GameCommon.ConvertLongToDateTime(emailtime); data.emailtime = sdt.ToString("yyyy年MM月dd日HH:mm"); object[] args = { contenttime, data.specialDiscript2 }; string formatcontent = string.Format(tdata.TipsText, args); data.infomation = formatcontent; } //if (data.emailitems.Count == 0) if (GameKind.HasFlag(3, flag) || GameKind.HasFlag(4, flag) || GameKind.HasFlag(5, flag)) { data.emailtype = MailType.HASGOODS; } else { data.emailtype = MailType.READONLY; } emilsdata_.Add(data.emailid, data); Email.GetEmailInstance().InitNewsUIData(); GameMain.hall_.m_Bulletin.OnEmailChange(EmailDataManager.GetNewsInstance().emilsdata_.Count <= 0); GameMain.hall_.GetPlayerData().mailNumber = (byte)EmailDataManager.GetNewsInstance().emilsdata_.Count; return(true); }
public void OnLog(string msg) { Debug.Log("DebugLog : " + msg); if (txtDebugLog == null) { return; } debugView.SetActive(true); //if (!debugView.activeSelf) debugView.SetActive(true); string txtLog = txtDebugLog.text; System.DateTime data = System.DateTime.Now; txtLog += "\n" + (data.Hour + ":" + data.Minute + ":" + data.Second + "." + data.ToString("fff")) + msg; txtDebugLog.text = txtLog; }
/// <summary> /// A DateTime extension method that converts this object to a short date long time string. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>The given data converted to a string.</returns> public static string ToShortDateLongTimeString(this System.DateTime @this) { return(@this.ToString("G", DateTimeFormatInfo.CurrentInfo)); }
void getTree(int treeNum) { if (tree1BtnText.text == "구매불가") { return; } SoundManager.Instance().PlaySfx(SoundManager.Instance().buyFood); int nowFood = MainSingleTon.Instance.cFood; int foodCost = System.Convert.ToInt32(tree1BtnText.text); string Query = ""; if (nowFood >= foodCost) { System.DateTime getTreeTime = System.DateTime.Now; Debug.Log(MainSingleTon.Instance.cFood); Query = "UPDATE managePlanetTable SET tree" + treeCount + " = " + treeNum + ", treeTouchT = \"" + getTreeTime.ToString("yyyy-MM-dd HH:mm:ss") + "\" Where rowid = " + MainSingleTon.Instance.rowid; SQLManager.GetComponent <MainSceneSQL>().UpdateQuery(Query); MainSingleTon.Instance.cFood -= foodCost; Query = "UPDATE userTable SET cFood = " + MainSingleTon.Instance.cFood; SQLManager.GetComponent <MainSceneSQL>().UpdateQuery(Query); } else { activeLake(); } setBuildingPanal(); setStoreText(); }
void OnDateChanged(System.DateTime time) { Debug.Log("OnDateChanged: " + time.ToString()); }
void OnGUI() { position = new Rect(position.x, position.y, 250, 200); GUILayout.BeginArea(new Rect(0, 7, 250, 200)); //Year GUILayout.BeginHorizontal(); if (GUILayout.Button("<", GUILayout.Width(65))) { CurrentDate = CurrentDate.AddYears(-1); } GUILayout.FlexibleSpace(); GUILayout.Label(CurrentDate.ToString("yyyy"), EditorStyles.boldLabel); GUILayout.FlexibleSpace(); if (GUILayout.Button(">", GUILayout.Width(65))) { CurrentDate = CurrentDate.AddYears(1); } GUILayout.EndHorizontal(); //Month GUILayout.BeginHorizontal(); if (GUILayout.Button("<", GUILayout.Width(65))) { CurrentDate = CurrentDate.AddMonths(-1); } GUILayout.FlexibleSpace(); GUILayout.Label(CurrentDate.ToString("MMMM"), EditorStyles.boldLabel); GUILayout.FlexibleSpace(); if (GUILayout.Button(">", GUILayout.Width(65))) { CurrentDate = CurrentDate.AddMonths(1); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); //Day int numDays = System.DateTime.DaysInMonth(CurrentDate.Year, CurrentDate.Month); Days = new List <string>(); for (int i = 1; i < numDays + 1; i++) { Days.Add(i.ToString()); } int newDay = GUILayout.SelectionGrid(CurrentDate.Day - 1, Days.ToArray(), 7) + 1; int diff = newDay - CurrentDate.Day; CurrentDate = CurrentDate.AddDays(diff); if (numDays <= 28) { GUILayout.Space(21); } EditorGUILayout.Space(); if (GUILayout.Button("Select")) { if (OnPicked != null) { OnPicked(this); } } GUILayout.EndArea(); }
void OnPickerClosed(System.DateTime time) { Debug.Log("OnPickerClosed: " + time.ToString()); }
/// <summary> /// A DateTime extension method that converts this object to a short date long time string. /// </summary> /// <param name="this">The @this to act on.</param> /// <param name="culture">The culture.</param> /// <returns>The given data converted to a string.</returns> public static string ToShortDateLongTimeString(this System.DateTime @this, CultureInfo culture) { return(@this.ToString("G", culture)); }