I'm sending timezone identifiers to our backend, and I'm facing a problem because sometimes I'm sending deprecated ones.
The problem is that this deprecated timezone is get from the phone system.
For instance, selecting "Washington D.C" on time settings I get "US/Eastern" when I call TimeZone.current.identifier.
Furthermore, if I call TimeZone.knownTimeZoneIdentifiers I get a list of ~400 items, but "US/Eastern" is not there!
How is it even possible that TimeZone.current.identifier is returning a timezone not in knownTimeZoneIdentifiers?
Related
When I try to get the last time that I contacted some contacts, the results has the value converted to "01/01/1970" but I know the real date and time of the last call (for example, it is 14/02/2016). I noted that in my logs the last saved call is that was at one and half year ago, but the call I try to find was in 2 years ago.
So, am I correct in understanding that after some long time the log loses the older calls and in the contacts2.db the last_time_contacted field updates to incorrect values?
LAST_TIME_CONTACTED is not somehow linked to the call log, it's just a timestamp value that is set on the contact.
01/01/1970 means a value of 0 for that field, i.e. that contact never had its LAST_TIME_CONTACTED value set, this can happen if that contact was recreated (re-synced, merged, split, etc.) since it was last contacted, erasing the previously set value.
Also note that LAST_TIME_CONTACTED can be updated not just by calls - sms, whatsapp, email apps, even social apps can and do update this value for a contact that was contacted via the app.
LAST_TIME_CONTACTED has been deprecated and not updated from Android.Q and later.
Reference
I wrote a .NET program that creates live events in Youtube, but I cannot set the correct starting time and some settings like Keywords, and Region. This is what I do, when I create the Broadcast I put the starting Date and Time this way:
oLiveBroadcast.Snippet.ScheduledStartTime = String.Format(CDate(txtScheduledStart.Text), "yyyy-MM-ddTHH:mm:sszzzz")
...but the GMT is always referred to US (GMT -8). I think that the problem is in the receiving field .Snippet.ScheduledStartTime which has a dateTime format not including GMT. What can I do?
I also didn't find how and whare to set Region (in my case Itali IT-it) and searching Keywords
Thanks
Quick environment overview:
I have an ASP.NET MVC/AngularJS application that is ultimately being hosted as an Azure Webrole. The data is stored in MongoDB hosted in the same Azure data center (via MongoLab). Development environment and staging environment (Azure) point to same MongoDB database and thus see the exact same data.
Issue:
Individual users of the application are stored with their preferred timezone as a string (TimezoneID). All dates in the app are stored as UTC times. Conversion to and from UTC times to a users specific timezone is done on the server via an extension method which ultimately calls:
return TimeZoneInfo.ConvertTimeFromUtc(UtcDate, _lookup[TimeZoneID]);
Nowhere in the entire app is there a DateTime.Now or any other date conversion I would expect to use the server time settings.
In a particular area of the application a date is being stored in Mongo (UTC). I can confirm that the date is correctly stored as UTC (based on the offset from my local time). When I retrieve that date from the data store and convert it back to my local time (Central Standard Time) I step over the above line of code and the conversion works fine and the local time is set. The result is sent to the client's browser as part of a Json result of an API call and displayed to the user correctly. During transport the MVC Json serializer parses the datetime into a format similar to:
EventDate: "/Date(1399407153971)/"
I parse this in Javascript and display accordingly and all is good.
When I deploy the exact same code to Azure (which points to the exact same data store in Mongo) the result that comes down via the API call appears to have applied the UTC transformation twice (meaning the regular 6 hour UTC offset is applied twice and the displayed date is 12 hours earlier than UTC...6 hours off of what I want).
I've updated the stored time in Mongo by a minute or two to make sure both sides update and they do (verifying the same data). I've modified the date/time settings of my local machine to see if it has any effect on my local results and it does not. I've changed the timezone for the selected user in the app and both my local result AND the Azure returned result adjust by the UTC offset difference between Central Standard Time and the new time zone (meaning if I switch to Mountain Time the result of both the local result and the Azure result adjust by 1 hour...but are still 6 hours off). I've confirmed via Chrome Dev Tools that the date in question that is retrieved at the client (via Json) is different based on whether the site hit was the remove (Azure) environment or local environment (meaning it isn't being modified incorrectly anywhere on the client after-the-fact)
Here is the most telling thing:
If I convert the date to a string prior to returning it to the client the string sent down appears correct in the Json response. If I leave it as a .NET DateTime type (as a property of a complex object) the Json serializer appears to translate it again but ONLY when hosted in Azure. This has pointed me to the issue being somehow related to the DateTimeKind of the date I'm returning. Although, at this point, I'm too lost in the weeks to see why the difference between my local environment and the Azure host environment in serialization and why one things a time is correct and the other converts it twice. If the DateKindTime was wrong wouldn't both environments perform the same conversion?
Thanks for reading through this and I'd appreciate any ideas to address anyone has.
It's difficult to say for sure without seeing more code, but could it be that the problem is with conversion on the way in, rather than on the way out? You said that you're using TimeZoneInfo.ConvertTimeFromUtc for the output. Are you also using TimeZoneInfo.ConvertTimeToUtc on the other side? If so, that's likely the source of picking up your local time zone.
You might also somewhere have a call to DateTime.ToUniversalTime, which again - uses the local time zone.
Another area which might be the culprit - when you retrieve your value from Mongo, check the Kind of the values coming back. If they're Unspecified, then when they are serialized to JSON, they will be treated as if they were Local. basically, there's a ToUniversalTime call going on under the hood. So you may need to explicitly call DateTime.SpecifyKind to set the value to Utc before it goes out the door.
With specific regards to Azure, it follows best practices of setting the server time zone to UTC. You could try that on your own machine and see if you get similar results.
Of course, you really don't want the server's time zone to influence the result at all.
You may want to consider creating a new project with a minimal, complete, and verifiable example. That will help you verify your assumptions, and will likely track down the source of the problem. If it still fails, well then you'll be in much better shape for asking for help.
That was a long post :)
If I were you I would transfer all dateTimes in UTC format. The server basically must work with UTC time as far as I'm concerned. Transformation to client time must be applied at clients side. You can use momentjs library that proved to be very fine library for working with dates and times.
On client side do something like this
var date = {
utc: '/Date(1399407153971)/', //time that you have recieved
offset: 240
}
var localTime = moment.utc(date.utc).zone(date.offset).format('DD/MM/YYYY hh:mm');
I hope this helps
UPD
As Matt Johnson pointed out you can make it even shorter for current time zone.
var localTime = moment('/Date(1399407153971)/').format('DD/MM/YYYY hh:mm');
Hi I was trying send meeting invites through my asp.net MVC application. There was a requirement to show which timezone this invite was created as in following image. I tried various things as told by Microsoft support, neither of them worked.
As per Microsoft Exchange Server support's advice I created following.
TZID:Sri Jayawardenepura
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Sri Jayawardenepura:20140416T033000Z
DTSTAMP:20140327T113138Z
DTEND;TZID=Sri Jayawardenepura:20140416T060000Z
LOCATION: Board room
After adding TZID inside DTSTART, it is not coming as invite to gmail.
but following works fine as invitation both in outlook configured with Exchange Server and webmails like gmail.
TZID:Sri Jayawardenepura
BEGIN:STANDARD
TZOFFSETFROM:+0530
TZOFFSETTO:+0530
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART:20140318T033000Z
DTSTAMP:20140327T122640Z
DTEND:20140318T060000Z
LOCATION: Board room
however that requirement of showing timezone where invite was created not fulfilled yet.
Can anyone help me. Thanks in advance.
If you look at http://www.kanzaki.com/docs/ical/dateTime.html it states that UTC time is identified by a Z suffix character as well as The TZID property parameter MUST NOT be applied to DATE-TIME properties whose time values are specified in UTC.
I would suspect that if you are using a timezone identifier that you need to remove the Z from the end of the date to get it to work properly.
EDIT: So, I was having troubles with timezones before as well, so I had only used UTC time, however I just got one to work with a timezone, so I hope this helps. Inside VTIMEZONE, you have a STANDARD, but you do not have a DTSTART inside the STANDARD. Again, quoting from the above link, The standard or daylight component MUST include the "DTSTART", "TZOFFSETFROM" and "TZOFFSETTO" properties.
It is not RFC5545 compliant but many calendars will expect a TZID to be compatible with the Olson DB and also may expect to have the calendar property X-WR-TIMEZONE set.
What I have seen is that when doing all of above you increase your calendar compatibility ratio.
I have an app that creates and stores a session with a given start date. The user would create a new work session and when they start it, the current time would get saved to the database. The app needs to count time between the start and end of a work session. However, I need to be able to pause, restart, and continue sessions, so I need to get the date from the database.
Say a user starts at 10:30am on a particular day and continues their work session until 12:30pm. Say they need to close the app for whatever reason and come back to the work session. The session needs to count and show the current elapsed time since the beginning. So, I wanted to make an NSDate object with the start time taken from the database...but I can't. At least, I can't find a way of initializing a Date object with a string or even a set of parameters. I'm sure there's a way to do it, but I can't find one.
Take a look at the dateFromString: method on NSDateFormatter
you can start with the Apple Doc here
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW1
could type up examples, but I think the documentation contains some