public ActionResult GetTime()
        {
            var solar  = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, TimeZoneID);
            var lunar  = solar.ToLunar(TimeZone);
            var output = new {
                SolarCalendar = new {
                    HH = solar.Hour,
                    mm = solar.Minute,
                    ww = solar.DayOfWeek,
                    dd = solar.Day,
                    MM = solar.Month,
                    yy = solar.Year
                },
                LunarCalendar = new {
                    dd = lunar.Day,
                    MM = lunar.Month,
                    yy = lunar.Year
                }
            };

            return(new JsonResult(output)
            {
                ContentType = "application/json",
                StatusCode = StatusCodes.Status200OK,
                SerializerSettings = new JsonSerializerOptions()
                {
                    WriteIndented = true
                }
            });
        }
Exemple #2
0
        public IActionResult GetTimeByTimezone(string timezone)
        {
            DateTime date            = DateTime.Now;
            DateTime destinationDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date, timezone);

            return(View(destinationDate));
        }
        private void acceptButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime CurTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, SystemTimeZones[TimeZonesListBox.SelectedIndex].Id);
            byte     WeekDay = (byte)CurTime.DayOfWeek;

            if (WeekDay != 0)
            {
                WeekDay--;
            }
            else
            {
                WeekDay = 6;
            }

            WeekDay++; //дни c 1 по 7

            TimeSet.Seconds    = DecToBin((byte)CurTime.Second);
            TimeSet.Minutes    = DecToBin((byte)CurTime.Minute);
            TimeSet.Hours      = DecToBin((byte)CurTime.Hour);
            TimeSet.WeekDay    = WeekDay;
            TimeSet.Date       = DecToBin((byte)CurTime.Day);
            TimeSet.Month      = DecToBin((byte)CurTime.Month);
            TimeSet.Year       = DecToBin((byte)(CurTime.Year - 2000));
            TimeSet.TimeZoneId = (byte)TimeZonesListBox.SelectedIndex;

            this.DialogResult = true;
        }
Exemple #4
0
        public void TimeCommand(int source, List <object> args, string raw)
        {
            switch (Convars.TimeMode)
            {
            // If the synchronization is disabled, show a message and return
            default:
                Debug.WriteLine("Time synchronization is Disabled");
                return;

            // If the sync mode is set to Real, show the IRL Time
            case SyncMode.Real:
                DateTime tz = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, Convars.TimeZone);
                Debug.WriteLine($"Time Zone is set to {Convars.TimeZone}");
                Debug.WriteLine($"The current time is {tz.Hour:D2}:{tz.Minute:D2}");
                return;

            // For Dynamic and Static
            case SyncMode.Dynamic:
            case SyncMode.Static:
                // If we have zero arguments, show the time and return
                if (args.Count == 0)
                {
                    Debug.WriteLine($"The time is set to {hours:D2}:{minutes:D2}");
                    return;
                }

                // If there is single argument and is separated by :
                if (args.Count == 1)
                {
                    // Convart it to a string
                    string repr = args[0].ToString();

                    // If it contains two dots
                    if (repr.Contains(":"))
                    {
                        // Convert the items and add them back
                        string[] newArgs = repr.Split(':');
                        args.Clear();
                        args.AddRange(newArgs);
                    }
                    // If it does not, add a zero
                    else
                    {
                        args.Add(0);
                    }
                }

                // Now, time to parse them
                if (!int.TryParse(args[0].ToString(), out int newHours) || !int.TryParse(args[1].ToString(), out int newMinutes))
                {
                    Debug.WriteLine("One of the parameters are not valid numbers.");
                    return;
                }

                // If we got here, the numbers are valid
                SetTime(newHours, newMinutes);
                Debug.WriteLine($"The time was set to {newHours:D2}:{newMinutes:D2}");
                break;
            }
        }
Exemple #5
0
        public static DateTime GetCurrentTime(DateTime?timeToConvert = null)
        {
            DateTime serverTime = timeToConvert ?? DateTime.Now;
            DateTime _localTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(serverTime, TimeZoneInfo.Local.Id, "E. South America Standard Time");

            return(_localTime);
        }
Exemple #6
0
        public ActionResult FileManager(filemanagermodel objmodel)
        {
            try
            {
                ManageFileManager filemanager = new ManageFileManager();
                string            strRet      = "Please check entered details. Something wrong with that";

                if (ModelState.IsValid)
                {
                }
                else
                {
                    var istdate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, TimeZoneInfo.Local.Id, "India Standard Time");

                    objmodel.uploadeddate1 = CommonMethod.ToDDMMYYYY(istdate);
                    objmodel.filedate1     = CommonMethod.ToDDMMYYYY(istdate);

                    ViewBag.compid    = new SelectList(filemanager.CompList, "compid", "compname");
                    ViewBag.compfinyr = new SelectList(new List <compfinyearlist>(), "compfinid", "finyear");

                    ViewBag.filecatlist = new SelectList(filemanager.FileCatList, "catid", "catname");
                    ViewBag.filesubcat  = new SelectList(new List <mstfilesubcategory>(), "subcatid", "subcatname");
                }
            }
            catch
            {
                ViewBag.Error = "Sorry,Detail is not inserted";
            }
            return(View(objmodel));
        }
        public List <Tz> GetTimes(DateTime selectedDate, string timezoneId)
        {
            var result = new List <Tz>();

            for (int i = 0; i < 24; i++)
            {
                var date = new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day, i, 0, 0);
                var tz   = new Tz();
                tz.BaseDateTime = date;
                tz.DateTime     = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date, timezoneId);
                tz.TimeZoneId   = timezoneId;
                if (tz.DateTime.Day > date.Day)
                {
                    tz.IsPlusOneDay = true;
                }

                if (tz.DateTime.Day < date.Day)
                {
                    tz.IsMinusOneDay = true;
                }

                result.Add(tz);
                i++;
            }

            return(result);
        }
Exemple #8
0
    static void ConvertToMountainTime(DateTime utc)
    {
        DateTime mountain = TimeZoneInfo.ConvertTimeBySystemTimeZoneId
                                (utc, "Mountain Standard Time");

        Console.WriteLine("{0} (UTC) = {1} Mountain time", utc, mountain);
    }
        public void TimingConversionNET()
        {
            var timezone = new string[] { "Romance Standard Time",
                                          "Russian Standard Time",
                                          "E. South America Standard Time",
                                          "Pacific Standard Time",
                                          "India Standard Time" };

            var rnd = new Random(188);

            for (int i = 0; i < 10000; i++)
            {
                var src  = rnd.Next(0, 4);
                var dest = rnd.Next(0, 4);
                var date = new DateTime(rnd.Next(1900, 2020), rnd.Next(1, 12), rnd.Next(1, 28), rnd.Next(0, 23), rnd.Next(0, 59), rnd.Next(0, 59), DateTimeKind.Unspecified);
                try
                {
                    TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date, timezone[src], timezone[dest]);
                }
                catch (ArgumentException)
                {
                    // some local dates are not valid as they fall into the period of when time is moved forward
                    // so adjust by 1 hour.
                    date = date.AddHours(1);
                    TimeZoneInfo.ConvertTimeBySystemTimeZoneId(date, timezone[src], timezone[dest]);
                }
            }
        }
Exemple #10
0
        public static DateTime GetMexicoCentralTime()
        {
            var mexicoTimeZone    = "Central Standard Time (Mexico)";
            var convertedDateTime = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, mexicoTimeZone);

            return(convertedDateTime);
        }
    protected void rgAdminSMS_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

        switch (e.DetailTableView.Name)
        {
        case "AccountType":
        {
            int LoginId = Convert.ToInt32(dataItem.GetDataKeyValue("LoginId"));
            e.DetailTableView.DataSource = new AdministrationBAL().GetAccountType(LoginId);
            break;
        }

        case "Account":
        {
            int       LoginId       = Convert.ToInt32(dataItem.GetDataKeyValue("LoginId"));
            int       AccountTypeId = Convert.ToInt32(dataItem.GetDataKeyValue("AccountTypeId"));
            DataTable dtAccountType = new AdministrationBAL().GetSMSDetails(LoginId, AccountTypeId);
            foreach (DataRow dr in dtAccountType.Rows)
            {
                dr["CreatedOn"] = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Convert.ToDateTime(dr["CreatedOn"]), "India Standard Time");
            }
            e.DetailTableView.DataSource = dtAccountType;
            //e.DetailTableView.DataSource = new AdministrationBAL().GetSMSDetails(LoginId, AccountTypeId);
            break;
        }
        }
    }
Exemple #12
0
    private int CheckPasswordExpiry()
    {
        BusinessLogic bl = new BusinessLogic();

        string ExpiryDate = bl.GetExpiryDate(txtLogin.Text, Request.Cookies["Company"].Value);

        DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
        string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");

        TimeSpan ts   = Convert.ToDateTime(ExpiryDate) - Convert.ToDateTime(dtaa);
        int      days = Convert.ToInt32(ts.TotalDays);

        return(days);

        //if (Convert.ToInt32(t.ToString("#0")) == 0)
        //{
        //    return true;
        //}
        //else if (Convert.ToInt32(t.ToString("#0")) < 0)
        //{
        //    return true;
        //}
        //else if (Convert.ToInt32(t.ToString("#0")) == 7)
        //{
        //    return retval;
        //}
        //else if ((Convert.ToInt32(t.ToString("#0")) < 7) && (Convert.ToInt32(t.ToString("#0")) > 0))
        //{
        //    return retval;
        //}
        //else
        //{
        //    return true;
        //}
    }
Exemple #13
0
    private bool CheckPasswordExpiry(string userName)
    {
        BusinessLogic bl = new BusinessLogic();

        string ExpiryDate = bl.GetExpiryDate(userName, Request.Cookies["Company"].Value);

        if (ExpiryDate == null || ExpiryDate.ToString() == string.Empty)
        {
            return(false);
        }
        else
        {
            DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
            string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");
            ExpiryDate = Convert.ToDateTime(ExpiryDate).ToString("dd/MM/yyyy");

            TimeSpan ts   = Convert.ToDateTime(ExpiryDate) - Convert.ToDateTime(dtaa);
            int      days = Convert.ToInt32(ts.TotalDays);

            if (days > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }

        return(false);
    }
        public static DateTime LocalTime(this WuLocation location)
        {
            var tzId = location?.Location?.tz ?? location?.Conditions?.local_tz_long ?? location?.TodayForecast?.date?.tz_long;

            var now = DateTime.Now;

            if (string.IsNullOrWhiteSpace(tzId))
            {
                return(now);
            }

            try {
                //var tzInfo = TimeZoneInfo.FindSystemTimeZoneById (location.Location.tz);

                return(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(now, tzId));
            } catch (TimeZoneNotFoundException tzEx) {
                System.Diagnostics.Debug.WriteLine(tzEx.Message);
                System.Diagnostics.Debug.WriteLine(tzId);

                return(now);
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex.Message);

                return(now);
            }
        }
Exemple #15
0
    protected void lnkBtnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            //if (!Helper.IsLicenced(Request.Cookies["Company"].Value))
            //{
            //    ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('This is Trial Version, Please upgrade to Full Version of this Software. Thank You.');", true);
            //    return;
            //}
            Reset();
            ModalPopupExtender2.Show();
            UpdateButton.Visible = false;
            AddButton.Visible    = true;
            UpdateButton.Visible = false;
            Session["LeadID"]    = "0";
            Session["contactDs"] = null;
            ShowLeadContactInfo();
            //txtCreationDate.Text = DateTime.Now.ToShortDateString();

            DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
            string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");
            txtCreationDate.Text = dtaa;

            txtCreationDate.Focus();

            txtLeadNo.Text = "- TBA -";
            DropDownList1.SelectedItem.Text = "NO";
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
        public ActionResult EndingSoon()
        {
            SearchViewModel model = new SearchViewModel();

            var auctions = RetrieveAuctionsFromCache();

            DateTime central = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(
                DateTime.UtcNow, "Central Standard Time");

            foreach (Auction auction in auctions)
            {
#if DEBUG
                //Do 5 days if in DEBUG to make sure we get results
                auction.AuctionItems.Where(x => x.EndDateTime <= central.AddDays(5)).ForEach(model.AuctionItems.Add);
#else
                auction.AuctionItems.Where(x => x.EndDateTime <= central.AddDays(1)).ForEach(model.AuctionItems.Add);
#endif
            }

            if (!model.AuctionItems.Any())
            {
                model.ErrorMessage = "No upcoming auctions found";
            }

            return(View(model));
        }
    protected void lnkBtnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            tbMain.Visible    = true;
            pnsApprov.Visible = true;
            pnsApprov.Enabled = false;
            pnsSave.Visible   = true;

            DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
            string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");
            txtDate.Text = dtaa;

            //lnkBtnAdd.Visible = false;
            btnCancel.Enabled = true;
            btnSave.Visible   = true;
            btnSave.Enabled   = true;
            btnUpdate.Visible = false;
            GrdTse.Visible    = false;
            pnsTime.Visible   = true;
            pnsTse.Visible    = true;
            ModalPopupExtender1.Show();
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Exemple #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            sDataSource = ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString();

            if (!IsPostBack)
            {
                loadLedger();

                txtStartDate.Text = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToShortDateString();

                DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
                string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");
                txtEndDate.Text = dtaa;

                divPrint.Visible = false;
                //txtEndDate.Text = DateTime.Now.ToShortDateString();
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Exemple #19
0
        public DateTime GetCurrentDateTime()
        {
            string   tz      = System.Web.Configuration.WebConfigurationManager.AppSettings["TimeZone"];
            DateTime DateNow = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Local);

            return(TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateNow, tz));
        }
Exemple #20
0
        public async Task <string> DeleteAdminPromotional(DeleteAdminPromotionalDto DeleteAdminPromotionalDto)
        {
            DateTime Presentdate = Convert.ToDateTime(GetPresentdate);
            DateTime Timezone    = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(Presentdate, TimeZoneInfo.Local.Id, DeleteAdminPromotionalDto.CountryTimezone);
            var      GetAdminPromotionaldetails = Repository.SingleOrDefault(x => x.Id == DeleteAdminPromotionalDto.PromotionalId);

            if (GetAdminPromotionaldetails.IsDefault == "0")
            {
                if (GetAdminPromotionaldetails.StartDate > Timezone)
                {
                    GetAdminPromotionaldetails.Status = 0;
                    await Repository.UpdateAsync(GetAdminPromotionaldetails);

                    return("Admin Promotional deleted successfully");
                }
                else
                {
                    return("Sorry you are not allowed to update,Admin Promotional is live now");
                }
            }
            else
            {
                GetAdminPromotionaldetails.Status = 0;
                await Repository.UpdateAsync(GetAdminPromotionaldetails);

                return("Admin Promotional deleted successfully");
            }
        }
Exemple #21
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            //await _dialog.RunAsync(turnContext, _userState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
            var text = turnContext.Activity.Text.ToLowerInvariant();

            if (text.Contains("recent"))
            {
                var latestOrders = await _cateringDb.GetRecentOrdersAsync();

                var users = latestOrders.Items;
                await SendHttpToTeams(HttpMethod.Post, MessageFactory.Attachment(new CardResource("RecentOrders.json").AsAttachment(
                                                                                     new
                {
                    users = users.Select(u => new
                    {
                        lunch = new
                        {
                            entre          = String.IsNullOrEmpty(u.Lunch.Entre) ? "N/A" : u.Lunch.Entre,
                            drink          = String.IsNullOrEmpty(u.Lunch.Drink) ? "N/A" : u.Lunch.Drink,
                            orderTimestamp = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(u.Lunch.OrderTimestamp, "Pacific Standard Time").ToString("g")
                        }
                    }).ToList()
                })), turnContext.Activity.Conversation.Id);
            }
            else
            {
                await SendHttpToTeams(HttpMethod.Post, MessageFactory.Attachment(new CardResource("EntreOptions.json").AsAttachment()), turnContext.Activity.Conversation.Id);
            }
        }
    private void ConvertZonesById()
    {
        // <Snippet3>
        DateTime currentTime = DateTime.Now;

        Console.WriteLine("Current Times:");
        Console.WriteLine();
        Console.WriteLine("Los Angeles: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Pacific Standard Time"));
        Console.WriteLine("Chicago: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Central Standard Time"));
        Console.WriteLine("New York: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Eastern Standard Time"));
        Console.WriteLine("London: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "GMT Standard Time"));
        Console.WriteLine("Moscow: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Russian Standard Time"));
        Console.WriteLine("New Delhi: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "India Standard Time"));
        Console.WriteLine("Beijing: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "China Standard Time"));
        Console.WriteLine("Tokyo: {0}",
                          TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Tokyo Standard Time"));
        // </Snippet3>
    }
        public DateDiffTransform(IContext context) : base(context, PartReturns[context.Transform.TimeComponent])
        {
            var input = MultipleInput().TakeWhile(f => f.Type.StartsWith("date")).ToArray();

            _start = input[0];

            if (Context.Transform.TimeComponent.In("year", "month"))
            {
                Context.Warn("datediff can not determine exact years or months.  For months, it returns (days / (365/12.0)).  For years, it returns (days / 365).");
            }

            if (PartReturns.ContainsKey(context.Transform.TimeComponent))
            {
                if (input.Count() > 1)
                {
                    // comparing between two dates in pipeline
                    _end       = input[1];
                    _transform = row => row[context.Field] = Parts[context.Transform.TimeComponent]((DateTime)row[_start], (DateTime)row[_end]);
                }
                else
                {
                    // comparing between one date in pipeline and now (depending on time zone)
                    var fromTimeZone = Context.Transform.FromTimeZone == Constants.DefaultSetting ? "UTC" : Context.Transform.FromTimeZone;
                    var now          = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, fromTimeZone);
                    _transform = row => row[context.Field] = Parts[context.Transform.TimeComponent](now, (DateTime)row[_start]);
                }
            }
            else
            {
                Context.Warn($"datediff does not support time component {Context.Transform.TimeComponent}.");
                var defaults = Constants.TypeDefaults();
                _transform = row => row[Context.Field] = Context.Field.Default != Constants.DefaultSetting ? Context.Field.Convert(Context.Field.Default) : defaults[Context.Field.Type];
            }
        }
        public static DateTime ToTimeZoneTime(this DateTime inValue, string timeZoneId)
        {
            var newDt = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(inValue, "UTC", timeZoneId);

            return((timeZoneId.Equals(TimeZoneInfo.Local.Id, StringComparison.InvariantCultureIgnoreCase)) ?
                   newDt.SetKind(DateTimeKind.Local) : newDt);
        }
    protected void frmViewAdd_ItemCreated(object sender, EventArgs e)
    {
        try
        {
            if (this.frmViewAdd.FindControl("txtStartDateAdd") != null)
            {
                //((TextBox)this.frmViewAdd.FindControl("txtStartDateAdd")).Text = DateTime.Now.ToString("dd/MM/yyyy");

                DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
                string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");

                ((TextBox)this.frmViewAdd.FindControl("txtStartDateAdd")).Text = dtaa;
            }

            if (this.frmViewAdd.FindControl("txtEndDateAdd") != null)
            {
                DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
                string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");

                ((TextBox)this.frmViewAdd.FindControl("txtEndDateAdd")).Text = dtaa;

                //((TextBox)this.frmViewAdd.FindControl("txtEndDateAdd")).Text = DateTime.Now.AddYears(1).ToString("dd/MM/yyyy");
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
        public void ConvertTime2()
        {
            DateTimeOffset utc = DateTimeOffset.UtcNow;
            var            ist = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(utc, "India Standard Time");

            Console.WriteLine("India Standard Time {0} {1}", ist, ist.Offset);
        }
        public ActionResult Reservation(int unitid)
        {
            DateTime today = DateTime.Now;

            today = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(today, TimeZoneInfo.Local.Id, "Singapore Standard Time");

            //defaults
            CarReservation reservation = new CarReservation();

            reservation.DtTrx       = today;
            reservation.DtStart     = today.AddDays(2).ToString();
            reservation.DtEnd       = today.AddDays(3).ToString();
            reservation.EstHrPerDay = 0;
            reservation.EstKmTravel = 0;
            reservation.JobRefNo    = 0;
            reservation.SelfDrive   = 1;     //with driver = 0, self drive = 1;

            ViewBag.CarUnitId = new SelectList(db.CarUnits, "Id", "Description", unitid);

            var carrate = db.CarRates.Where(d => d.CarUnitId == unitid).FirstOrDefault();

            ViewBag.CarRate      = carrate.Daily;
            ViewBag.objCarRate   = carrate; // db.CarRates.Where(d => d.CarUnitId == unitid);
            ViewBag.Destinations = db.CarDestinations.Where(d => d.CityId == 1).OrderBy(d => d.Kms).ToList();
            ViewBag.UnitId       = unitid;

            return(View(reservation));
        }
Exemple #28
0
 public WSRecepcionPOSTReceptor()
 {
     this.receptor = new EmisorReceptor();
     this.emisor   = new EmisorReceptor();
     //this.fecha = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss");
     this.fecha = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "Central America Standard Time");
 }
Exemple #29
0
        public async Task <CurrentTimeQuery> GetTimeByTimezone(string ip, string timezone)
        {
            var utcTime             = DateTime.UtcNow;
            var serverTime          = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, timezone);
            var timezoneDisplayName = TimeZoneInfo.FindSystemTimeZoneById(timezone).DisplayName;
            var timeLog             = new CurrentTimeQuery
            {
                UTCTime  = utcTime,
                ClientIp = ip,
                Time     = serverTime,
                Timezone = timezoneDisplayName
            };

            using (var db = new ClockworkContext())
            {
                await db.CurrentTimeQueries.AddAsync(timeLog);

                var count = db.SaveChanges();
                Console.WriteLine("{0} records saved to database", count);

                Console.WriteLine();
                foreach (var CurrentTimeQuery in db.CurrentTimeQueries)
                {
                    Console.WriteLine(" - {0}", CurrentTimeQuery.UTCTime);
                }
            }

            return(timeLog);
        }
Exemple #30
0
        public static DateTime GetCurrentTime()
        {
            var serverTime = DateTime.Now;
            var localTime  = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(serverTime, TimeZoneInfo.Local.Id, "Russian Standard Time");

            return(localTime);
        }