为什么要使用时区来开始&在活动中结束日期时间 [英] Why use timezone for start & end datetime in events

查看:122
本文介绍了为什么要使用时区来开始&在活动中结束日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道存储事件开始和放置是理想的做法。通过从本地时间转换为UTC时间来结束数据库表中的日期时间值。然后在日历上显示它时将其转换回当地时间或用户首选时区。



但我无法理解为什么Google存储时区名称以便开始&安培;以下代码中的结束日期时间



I know it is ideal practice to store event start & end datetime values in the database table by converting from local time to UTC time. And then while displaying it on the calendar convert it back to the local time or user prefered timezone.

But I can't understand why is Google storing timezone name for start & end datetime in the below code

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10}
    ]
  }
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});





我尝试了什么:



我正在尝试创建一个简单的警报具有时区支持的应用程序。我将日期时间值存储在数据库表中,方法是将它们从本地时间转换为UTC



What I have tried:

I am trying to create a simple alarm app with timezone support. I am storing datetime values in the DB table by converting them from local time to UTC

推荐答案

考虑从3月10日到3月12日运行的事件,夏令时将持续于3月11日生效。在这种情况下,洛杉矶活动开始时的时区将是PST(太平洋标准时间),最后是PDT(太平洋夏令时)。
Consider an event running from 10 March to 12 March, with daylight saving time going into effect on 11 March. In that case the time zone at the start of a Los Angeles event would be PST (Pacific Standard Time) and at the end it would be PDT (Pacific Daylight Time).


这篇关于为什么要使用时区来开始&在活动中结束日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆