How can I handle time zones in my webapp?

When John searches the event, he will know that it happened at 9:00 but what should he enter in the web browser? He won't find anything when he just enters "9:00" as timestamp because that might be Zurich or New York time (since the event hasn't been found, the app has no way to know that it happened in Sidney, so it can't automatically select the correct time zone).

What is a good way to ask the user for a timestamp that might include the time zone?

The second issue is how to display the results. If teams from all over the globe need to discuss the event (and find related events, think of a cracker attack that targets several sites all over the globe at once).

What is a good example for displaying timestamps that might have been created in a different time zone?

Note: Please concentrate on the usability of the requirement. I can figure out the database mapping myself. Currently, I'm unsure about the work flow. It should ask/present the necessary information in an non-intrusive/intuitive way. If you can, give a link to an existing web app which already solves this.

45285 次浏览

mp3 files sometimes throw strange mime types as per this answer: https://stackoverflow.com/a/2755288/14482130

  • Add an option to show/hide this timezone dropdown manually.
  • If you are doing some user validation do not allow 'application/octet-stream' or 'application/x-zip-compressed' as suggested above since they can contain be .exe or other potentially dangerous files.

  • Always store timestamps in UTC.
  • Hope it helps! :)

    or something like that. The other way is to store creation time zone, and convert at runtime (this is particularly better in case then user will change meeting time). Either way the main reason is to be able to restore original creation time so user can refer to it.

    Overall, I would display UTC time, the local time, the creation time, and the creation time zone (i.e. the local time and time zone of the event where it was created) sorted by UTC time, so you can see which event comes first, in case two different events were scheduled for 9:00 in two different time zones.

    It's a unified diff hunk identifier. This is documented by GNU Diffutils.

    ually differ between the two files have one of the following indicator characters in the left print column:

      The unified output format starts with a two-line header, which looks like this:

      --- from-file from-file-modification-time
      +++ to-file to-file-modification-time
      
    • +

      The time stamp looks like 2002-02-21 23:30:39.942229878 -0800 to indicate the date, time with fractional seconds, and time zone. The fractional seconds are omitted on hosts that do not support fractional time stamps.

      A line was added here to the first file.
    • -

      You can change the header's content with the --label=label option; see See Alternate Names.

      A line was removed here from the first file.
    timezone from drop down.Lets not burden user by giving options of all

    Simple example analysis

    timezones of world.First option of dropdown should be current time

    The format is basically the same the diff -u unified diff.

    zone of user's device. after that timezones from his history of

    For instance:

    diff -u <(seq -w 16) <(seq -w 16 | grep -Ev '^(02|03|14|15)$')
    
    timezones, then UTC and then remaining timezones which he has never

    Here we removed lines 2, 3, 14 and 15. Output:

    @@ -1,6 +1,4 @@
    01
    -02
    -03
    04
    05
    06
    @@ -11,6 +9,4 @@
    11
    12
    13
    -14
    -15
    16
    
    used till date.

    @@ -1,6 +1,4 @@ means:

      4.How to display the results, if teams from all over the globe need to discuss the event:

    • -1,6 means that this piece of the first file starts at line 1 and shows a total of 6 lines. Therefore it shows lines 1 to 6.

      1
      2
      3
      4
      5
      6
      

      I would like to divide this use case between number of teams 2 or more

      - means "old", as we usually invoke it as diff -u old new.

    • than 2.
      For just 2 teams, I would prefer that each team sees
    • +1,4 means that this piece of the second file starts at line 1 and shows a total of 4 lines. Therefore it shows lines 1 to 4.

      timestamp in its local time zone and other team's time zone. (I

      + means "new".

      personally prefer to talk in timezone of person at other end for his

      We only have 4 lines instead of 6 because 2 lines were removed! The new hunk is just:

      01
      04
      05
      06
      

    @@ -11,6 +9,4 @@ for the second hunk is analogous:

    • on the old file, we have 6 lines, starting at line 11 of the old file:

      11
      12
      13
      14
      15
      16
      
    • on the new file, we have 4 lines, starting at line 9 of the new file:

      11
      12
      13
      16
      
      convenience while scheduling a meeting). For more than 2 teams, its

      Note that line 11 is the 9th line of the new file because we have already removed 2 lines on the previous hunk: 2 and 3.

    better to consider more common timezone i.e. UTC. So in this case, every

    Hunk header

    user should see timestamp in 2 timezones, in UTC and in his default

    Depending on your git version and configuration, you can also get a code line next to the @@ line, e.g. the func1() { in:

    @@ -4,7 +4,6 @@ func1() {
    
    timezone.

    These suggestion are given with intention that user need not do any calculation in his local time but at the same he should be able communicate with other users fluently in their preferred time zone.

    This can also be obtained with the -p flag of plain diff.

    -diff-hunk-header-come-from">Where does the excerpt in the git diff hunk header come from?

  • Use the timezone that is most relevant to the user.

    When using myDelegate -= eventHandler ReSharper (version 6) issues:

    Delegate subtraction has unpredictable result

    If you know the user is going to be in or travelling to Sydney for the event, then they will be thinking in that timezone when arranging transport to the event. The fact that they're currently in New York is largely irrelevant. And of course, if your app shows dates in a variety of timezones, it should always show the timezone next to the date, e.g. 09:00 EST.

    The rational behind this is explained by JetBrains here. The explanation makes sense and, after reading it, I'm doubting all my uses of - on delegates.

    How then,

      If it doesn't clutter your interface too much, you could display dates in the event timezone and local timezone, e.g. 2012-06-13 09:00 EST (2012-06-12 19:00 EDT).

    • can I write a non-auto event without making ReSharper grumpy?
    • I would argue that searching is a similar problem, with one caveat: we can tolerate false positives (getting a result we weren't expecting), but we can't stand false negatives (not getting a result we were expecting).

    • or, is there a better and/or "correct" way to implement this?
    • Again, I'd focus on searching the most relevant timezone to the user (e.g. event timezone), and give these results priority in the search results, but you can also return events that match in other timezones that are relevant to the user (e.g. local time). If you do this, you should show the event date in the matching timezone, especially if you highlight matching text.

  • Timezone lookup from latitude longitude

  • You should not directly use delegates to sum or subtract. Instead your field

    MyHandler _myEvent;
    

    Should be instead declared as an event as well. This will solve the problem without risking your solution and still have the benefit of event usage.

    event MyHandler _myEvent;
    

    I know its just about showing some idea how to solve this problem. But see how accurate & light-weight it becomes on users when the Timezone is determined by using device APIs

    Usage of delegate sum or subtract is dangerous because you can lose events when simply assigning the delegate (as per declaration, the developer will not directly infer this is a Multicast delegate as when it is declared as an event). Just to exemplify, if the property mentioned on this question was not flagged as an event, the code below will case the two first assignments to be LOST, because someone simply assigned to the delegate (which is also valid!).

    myObject.MyEvent += Method1;
    myObject.MyEvent += Method2;
    myObject.MyEvent = Method3;
    

    Hope it helps!