当前位置: 首页 > news >正文

华为企业建设网站的目的推广赚钱 每单5元

华为企业建设网站的目的,推广赚钱 每单5元,盐城z做网站,二维码生成器在线制作二维码时区的定义 我们使用经纬度[1]来标识地球上的任意一个点。 理论时区 不像纬度有赤道作为自然的起点#xff0c;经度没有自然的起点而使用经过伦敦格林尼治天文台旧址的子午线作为起点。 理论时区的宽度是15#xff0c;所以一共有 360 / 15 24 个时区#xff0c;一天有 24 小…时区的定义 我们使用经纬度[1]来标识地球上的任意一个点。 理论时区 不像纬度有赤道作为自然的起点经度没有自然的起点而使用经过伦敦格林尼治天文台旧址的子午线作为起点。 理论时区的宽度是15°所以一共有 360 / 15 24 个时区一天有 24 小时所以每个时区正好对应一个小时。自子午线向东这些时区的名称为中时区以子午线为中心的时区、东一区、东二区...东十二区、西十一区、西十区...西一区[2]。 由于地球的自转方向为自西向东所以越东的时区时间越早。 实际时区 为了避开国界线有的时区的形状并不规则而且比较大的国家以国家内部行政分界线为时区界线这是实际时区即法定时区。[2] 同一国家可以有不同的时区同一国家也可以是同一个时区。 比如美国的夏威夷州是 UTC-10而加利福尼亚州是 UTC-8整个中国的理论时区横跨了从东五区UTC5到东九区UTC9共计五个时区但国家只有一个时区北京时间时区会变化 Why is subtracting these two times (in 1927) giving a strange result? 时区的 offset 不正确[4] 有人推测是时区数据库错了而不是 pytz 的问题。但我在其他编程语言的时区库中没有搜索到相关问题。 import datetime import pytz shanghai_tz pytz.timezone(Asia/Shanghai) # 在初始化中传入的时区的 offset 是不准确的datetime.datetime(2018, 1, 1, tzinfoshanghai_tz) datetime.datetime(2018, 1, 1, 0, 0, tzinfoDstTzInfo Asia/Shanghai LMT8:06:00 STD)# 要使用 pytz 文档中的 localize 才准确shanghai_tz.localize(datetime.datetime(2018, 1, 1)) datetime.datetime(2018, 1, 1, 0, 0, tzinfoDstTzInfo Asia/Shanghai CST8:00:00 STD) pytz.tzinfo.localize 的源码复杂 def localize(self, dt, is_dstFalse):Convert naive time to local time.This method should be used to construct localtimes, ratherthan passing a tzinfo argument to a datetime constructor.is_dst is used to determine the correct timezone in the ambigousperiod at the end of daylight saving time. from pytz import timezone fmt %Y-%m-%d %H:%M:%S %Z (%z) amdam timezone(Europe/Amsterdam) dt datetime(2004, 10, 31, 2, 0, 0) loc_dt1 amdam.localize(dt, is_dstTrue) loc_dt2 amdam.localize(dt, is_dstFalse) loc_dt1.strftime(fmt)2004-10-31 02:00:00 CEST (0200) loc_dt2.strftime(fmt)2004-10-31 02:00:00 CET (0100) str(loc_dt2 - loc_dt1)1:00:00Use is_dstNone to raise an AmbiguousTimeError for ambiguoustimes at the end of daylight saving time try:... loc_dt1 amdam.localize(dt, is_dstNone)... except AmbiguousTimeError:... print(Ambiguous)Ambiguousis_dst defaults to False amdam.localize(dt) amdam.localize(dt, False)Trueis_dst is also used to determine the correct timezone in thewallclock times jumped over at the start of daylight saving time. pacific timezone(US/Pacific) dt datetime(2008, 3, 9, 2, 0, 0) ploc_dt1 pacific.localize(dt, is_dstTrue) ploc_dt2 pacific.localize(dt, is_dstFalse) ploc_dt1.strftime(fmt)2008-03-09 02:00:00 PDT (-0700) ploc_dt2.strftime(fmt)2008-03-09 02:00:00 PST (-0800) str(ploc_dt2 - ploc_dt1)1:00:00Use is_dstNone to raise a NonExistentTimeError for these skippedtimes. try:... loc_dt1 pacific.localize(dt, is_dstNone)... except NonExistentTimeError:... print(Non-existent)Non-existentif dt.tzinfo is not None:raise ValueError(Not naive datetime (tzinfo is already set))# Find the two best possibilities.possible_loc_dt set()for delta in [timedelta(days-1), timedelta(days1)]:loc_dt dt deltaidx max(0, bisect_right(self._utc_transition_times, loc_dt) - 1)inf self._transition_info[idx]tzinfo self._tzinfos[inf]loc_dt tzinfo.normalize(dt.replace(tzinfotzinfo))if loc_dt.replace(tzinfoNone) dt:possible_loc_dt.add(loc_dt)if len(possible_loc_dt) 1:return possible_loc_dt.pop()# If there are no possibly correct timezones, we are attempting# to convert a time that never happened - the time period jumped# during the start-of-DST transition period.if len(possible_loc_dt) 0:# If we refuse to guess, raise an exception.if is_dst is None:raise NonExistentTimeError(dt)# If we are forcing the pre-DST side of the DST transition, we# obtain the correct timezone by winding the clock forward a few# hours.elif is_dst:return self.localize(dt timedelta(hours6), is_dstTrue) - timedelta(hours6)# If we are forcing the post-DST side of the DST transition, we# obtain the correct timezone by winding the clock back.else:return self.localize(dt - timedelta(hours6),is_dstFalse) timedelta(hours6)# If we get this far, we have multiple possible timezones - this# is an ambiguous case occuring during the end-of-DST transition.# If told to be strict, raise an exception since we have an# ambiguous caseif is_dst is None:raise AmbiguousTimeError(dt)# Filter out the possiblilities that dont match the requested# is_dstfiltered_possible_loc_dt [p for p in possible_loc_dt if bool(p.tzinfo._dst) is_dst]# Hopefully we only have one possibility left. Return it.if len(filtered_possible_loc_dt) 1:return filtered_possible_loc_dt[0]if len(filtered_possible_loc_dt) 0:filtered_possible_loc_dt list(possible_loc_dt)# If we get this far, we have in a wierd timezone transition# where the clocks have been wound back but is_dst is the same# in both (eg. Europe/Warsaw 1915 when they switched to CET).# At this point, we just have to guess unless we allow more# hints to be passed in (such as the UTC offset or abbreviation),# but that is just getting silly.## Choose the earliest (by UTC) applicable timezone if is_dstTrue# Choose the latest (by UTC) applicable timezone if is_dstFalse# i.e., behave like end-of-DST transitiondates {} # utc - localfor local_dt in filtered_possible_loc_dt:utc_time (local_dt.replace(tzinfoNone) - local_dt.tzinfo._utcoffset)assert utc_time not in datesdates[utc_time] local_dtreturn dates[[min, max][not is_dst](dates)] 总结一下对于 pytz获取带时区的时间要使用 tz.localize()将一个转换为另一个时区要 dt_with_tz.astimezone(another_tz)[5]。 程序设计 由于时区的最小单位是小时 所以如果要区分时区那么储存的时间必须包含小时比如你不能只储存到天2018-01-01所以储存的时间也要包含时区比如 MongoDB 储存的时区为 UTC The official BSON specification refers to the BSON Date type as the UTC datetime.[3] 程序中的时区不应该与机器所在的时区挂钩否则假如从中国机房迁移到美国机房那么你的程序就会出问题。 只需要一个时区 比如对于大部分中国的程序来说只需要考虑北京时间这一个时区。这里称这个时区为当地时区。 我认为在程序中前端、后端可以只使用当地时区。好处有 增强可读性减少混乱。比如调试时看北京时间肯定比 UTC 时间更直观避免不必要的时区转换如果数据库的时区可以修改那么也修改为当地时区否则使用数据库的时区。 比如 MongoDB 使用 UTC 时区储存不可更改我没有搜索到更改的配置那么如果有按月分表那么也使用 UTC 划分月这样数据库的时区就统一为了 UTC如果使用当地时区分月那么就会造成分歧。 需要多个时区 在程序内部使用 UTC 时区展示数据时使用用户选择的时区。 参考 https://zh.wikipedia.org/wiki/经纬度https://zh.wikipedia.org/wiki/时区https://docs.mongodb.com/manual/reference/bson-types/#document-bson-type-datehttps://bugs.launchpad.net/pytz/bug/1678858http://pytz.sourceforge.net/#localized-times-and-date-arithmetic转载于:https://www.cnblogs.com/jay54520/p/9431333.html
http://www.huolong8.cn/news/182496/

相关文章:

  • 广东工程建设监理协会网站企业管理咨询上班好吗
  • 网站顶部图片素材网站上的图是怎么做的
  • 浙江专业网站seo郑州有哪些互联网公司
  • wordpress打赏怎么用seo资源网
  • 商城网站代理系统solidworks永久免费版
  • 青州网站网站建设云南推广
  • 殡葬网站建设吉林东奥建设集团网站
  • wordpress秀佛山seo外包平台
  • 制作一个网站首页郑州百姓网招聘
  • 曹县 做网站的公司软件开发专业的就业方向
  • 电商网站构建怎么做网站的动效
  • 域名备案企业网站内容厦门市做网站优化
  • 怎样做网站api接口html教材电子版
  • 个人做网站能赚到钱吗网络推广网站公司推荐
  • 企业网站怎么优化珠海网站建设网络推广
  • 学网站开发怎么就业工业设计公司招聘
  • 自己做键盘的网站wordpress 404模板下载
  • 海外推广有哪些渠道网站优化排名公司
  • 为什么做彩票网站会被提示危险东莞网站建设套餐
  • 做网站抬头网站制作公司教你怎么制作网站
  • 一级a做爰片拍网站广西城乡和住房建设厅网站
  • 现在手机网站用什么做的象刀设计网站
  • 注册网站需要visa怎么办最近的seo网站优化排名
  • 设计师推荐网站网站建设评语
  • 泉州市住房与城乡建设网站江苏省建设工程施工安全网站
  • 国内 ui网站有哪些led灯散热片技术支持 东莞网站建设
  • 网站开发需要什么人员建立网页的几个步骤
  • 长春做公司网站wordpress关闭功能
  • 网站建设运营成本天津专业智能建站
  • 企业网站建设应该怎么做wordpress删除历史文档