datetimeoffset

Get time zone offset between two timezones for a given duration

╄→гoц情女王★ 提交于 2019-12-05 06:58:18
I wanted to know if there is a way to get the time zone offset for a given date range between two timezones for a given duration. getTimezoneOffset(startDate,endDate,timezone1,timezone2){ ...missing magic to go here... } should return the time zone offset which is valid for the a given duration. However if the offset changes, it should return the date range for which it's valid. So I am looking at something like this: getTimezoneOFfset("march 9 12 am", "march 15 12 am", "UTC", "US/NEW_YORK") return value something like this timezoneoffset[0]["range"]=[march 9 12am to march 11 2 am]

Cloud Firestore: Storing and querying for today's date over multiple UTC offsets?

浪尽此生 提交于 2019-12-05 06:16:33
问题 I'm writing a web app using Firestore that needs to be able to show "Today's Popular Posts" and I'm having trouble getting the queries right when considering users in different timezones. The dates are stored in the DB as UTC 0, then adjusted to the current user's UTC offset in the client via Moment.js. This works correctly. When adding a new post I use firebase.firestore.FieldValue.serverTimestamp() to store the current server timestamp in a field called timestamp , like so: const

How do I resolve issues with unsupported DateTimeOffsets in EF 6 using Sql Server?

社会主义新天地 提交于 2019-12-04 18:34:46
When I try to instantiate a DbContext I receive this message: System.NotSupportedException: There is no store type corresponding to the conceptual side type 'DateTimeOffset' of primitive type 'DateTimeOffset'. I am using Entity Framework version 6 on SQL Server. The constructor of the DbContext (with the line that throws the exception) looks like this: internal TestHubContext(string connectionStringName) : base(connectionStringName) { var objectContext = (this as IObjectContextAdapter).ObjectContext; ... } The entities are created using code-first, and look like this: public class Order { [Key

How many days to add for “semi-monthly”

我们两清 提交于 2019-12-04 05:57:09
I have a enum type called PaymentFrequency whose values indicate how many payments per year are being made... So I have public enum PaymentFrequency { None = 0, Annually = 1, SemiAnnually = 2, EveryFourthMonth = 3, Quarterly = 4, BiMonthly = 6, Monthly = 12, EveryFourthWeek = 13, SemiMonthly = 24, BiWeekly = 26, Weekly = 52 } Based on NumberOfPayments , PaymentFrequency , and FirstPaymentDate (of type DateTimeOffset) I want to calculate LastPaymentDate . But I am having issue figuring out how many time units (days, months) to add in case of SemiMonthly... switch (paymentFrequency) { // add

how to convert string to DateTime as UTC as simple as that

陌路散爱 提交于 2019-12-04 02:47:13
assume I have this string : How can I convert it to DateTimeOffset object that will have UTC time - means -00:00 as Time Zone - even if I run it on machine on a specific timezone? Assume String: "2012-10-08T04:50:12.0000000" Convert.ToDateTime("2012-10-08T04:50:12.0000000" + "Z"); --> DateTime d = {10/8/2012 6:50:12 AM} and I want it to be DateTime d = {10/8/2012 4:50:12 AM} as if it will understand I want the date as simple as it comes (BTW - my machine is in timezone +02:00) Use DateTimeOffset.Parse(string).UtcDateTime . 来源: https://stackoverflow.com/questions/13254211/how-to-convert-string

Cloud Firestore: Storing and querying for today's date over multiple UTC offsets?

我的未来我决定 提交于 2019-12-03 17:26:30
I'm writing a web app using Firestore that needs to be able to show "Today's Popular Posts" and I'm having trouble getting the queries right when considering users in different timezones. The dates are stored in the DB as UTC 0, then adjusted to the current user's UTC offset in the client via Moment.js . This works correctly. When adding a new post I use firebase.firestore.FieldValue.serverTimestamp() to store the current server timestamp in a field called timestamp , like so: const collectionRef = db.collection('posts'); collectionRef.add({ name: "Test Post", content: "Blah blah blah",

Changing current user timezone based on server UTC offset and user UTC offset

谁都会走 提交于 2019-12-03 16:48:07
im writing a twitter web service in php. When a user signs in, i receive this node: <utc_offset>-18000</utc_offset> I have to change the script's timezone so that it adapts to the user's real timezone. The only php function i have found for this is: date_default_timezone_set($timezone_identifier) but it won't let me use -18000 as a the $timezone_identifier parameter. So, how can i change the current user timezone based on two values: Server UTC offset and User UTC offset BTW, this is how i'm getting the server UTC offset value: $this_tz_str = date_default_timezone_get(); $this_tz = new

Remove Time Zone Offset from DateTimeOffset?

强颜欢笑 提交于 2019-12-03 14:21:48
This code: DateTimeOffset testDateAndTime = new DateTimeOffset(2008, 5, 1, 8, 6, 32, new TimeSpan(1, 0, 0)); //CLEAN TIME AND DATE testDateAndTime = testDateAndTime.DateTime.Date; var datesTableEntry = db.DatesTable.First(dt => dt.Id == someTestId); datesTableEntry.test= testDateAndTime; db.SaveChangesAsync(); ...produces this result in my database: 2008-05-01 00:00:00.0000000 -04:00 How should I revise my code so that it changes the time zone offset from -4:00 to +00:00 in testDateAndTime ? I have also tried: public Task<DateTimeOffset> SetTimeZoneOffsetToZero(DateTimeOffset dateTimeOffSetObj

Migrate SQL Server DateTime column to DateTimeOffset

删除回忆录丶 提交于 2019-12-03 08:29:58
问题 I have an old table with a few rows that has a datetime column. I want to switch this to datetimeoffset but i want to be able to transfer the data that already exists. So I'm doing something like: SET IDENTITY_INSERT Table_Temp ON INSERT INTO Table_Temp (Col0, ... ColN,) SELECT COl0,.... ColN, from Table_Original; SET IDENTITY_INSERT Table_Temp OFF This works but the offset set is 0 when i do the dattime to datetimeoffset assignment. Fortunately the offset that i want to set it to is the

Why does Json.NET DeserializeObject change the timezone to local time?

大城市里の小女人 提交于 2019-12-03 05:19:23
I'm using json.net to deserialize a DateTimeOffset , but it is ignoring the specified timezone and converting the datetime to the local offset. For example, given var content = @"{""startDateTime"":""2012-07-19T14:30:00+09:30""}"; When deserialised using: var jsonSerializerSettings = new JsonSerializerSettings() { DateFormatHandling = DateFormatHandling.IsoDateFormat, DateParseHandling = DateParseHandling.DateTimeOffset, DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind }; var obj = JsonConvert.DeserializeObject(content, jsonSerializerSettings); The obj will contain a property