首页 \ 问答 \ 如何根据国际化存储日期时间(how to store datetime as per internationalization)

如何根据国际化存储日期时间(how to store datetime as per internationalization)

我有一个项目,将有国家在选择国家顶部下拉菜单。 例如美国,印度和香港。 取决于国家选择的几个功能将被启用或禁用。

在项目中,我默认了基地国家,例如印度。 所以任何用户都会来。 我希望按照印度标准时间存储其登录日期时间,无论用户来自香港,美国还是印度。 我的网络服务器在美国托管。

那可能吗?


I am having a project which will have country dropdown at the top to select countries. For example USA, India and Hong Kong. Depends on the country selection several features will be enabled or disabled.

In project I am having base country by default for example India. So whenever any user will come. I want to store its login datetime as per Indian standard time regardless user is from Hong Kong, USA or India. My webserver is hosted in USA.

Is that possible?


原文:https://stackoverflow.com/questions/862379
更新时间:2022-04-19 11:04

最满意答案

不,如果不会导致未定义的行为。

该标准定义了24.1 / 7中的空迭代器范围 ,并且它没有说明为std::fill算法提供空范围会导致未定义的行为。

这实际上是人们对经过深思熟虑的实施所期望的。 使用自然处理emtpy范围的算法,强制要求检查调用者的空范围将是一个严重的设计错误。


No, if doesn't cause undefined behavior.

The standard defines empty iterator range in 24.1/7 and nowhere it says that supplying an empty range to std::fill algorithm causes undefined behavior.

This is actually what one would expect from a well-thought through implementation. With algorithms that handle emtpy range naturally, imposing the requirement to check for empty range on the caller would be a serious design error.

相关问答

更多
  • 什么会工作将使用构造函数(这将更有意义,而不是分配): class MyContainer { public: string value; MyContainer(const string& s): value(s) { } }; 那么第二个问题是该集合还要求其内容具有可比性。 至于原因, insert_iterator通过重载operator= : insert_iterator& operator= (typename Container::const_ref ...
  • 集合和地图根据排序条件保持元素的顺序。 对于不打破不变式的用户代码,映射key和集合中的整个元素必须是常量。 你的问题是存储的元素不是一个SmallObject而是一个const SmallObject 。 如果这不是有限的,你可以有: int init[] = { 1, 2, 3, 4, 5 }; std::set values( init, init+5 ); std::copy( values.begin(), values.end(), std::ostream_iterator< ...
  • 目前在C ++中没有all或any算法,但C ++ 0x将std::all_of和std::any_of算法添加到C ++标准库。 你的实现可能已经支持这些。 由于这两种算法都需要测试范围内的每个元素(至少直到他们发现匹配或不匹配),所以没有任何理由将它们专门用于不同类型的迭代器:与前向迭代器一起使用时的性能应该是与使用随机访问迭代器时的性能相同。 你all实施all很好; Visual C ++ all_of实现实际上是相同的,除了它使用for循环而不是while循环。 如何将这个最佳转换为迭代两个序列, ...
  • 它没有:-)这就是迭代器的要点 - 对它们运行的算法不需要知道底层容器的任何信息,反之亦然。 它是如何工作的呢? 那么,迭代器本身就有一些着名的属性 。 例如,“随机访问”迭代器允许任何算法通过常量访问迭代器的元素偏移量: std::vector vec = { 1, 2, 3, 4 }; assert(*(vec.begin() + 2) == 3); 对于一种排序,迭代器需要支持随机访问(为了以任意顺序访问第一个和结束迭代器之间的所有元素),并且它们需要是可写的(以便分配或以其他方式交换值) ...
  • 对于给定的容器, std::find和std::find_if可以在*::const_iterator上运行。 你偶然看到这些功能的签名,并误解它们吗? template InputIterator find(InputIterator first, InputIterator last, const Type& val); 请注意,这里的InputIterator只是一个模板类型参数的名称,任何const_iterator都会满足它的要 ...
  • 不,如果不会导致未定义的行为。 该标准定义了24.1 / 7中的空迭代器范围 ,并且它没有说明为std::fill算法提供空范围会导致未定义的行为。 这实际上是人们对经过深思熟虑的实施所期望的。 使用自然处理emtpy范围的算法,强制要求检查调用者的空范围将是一个严重的设计错误。 No, if doesn't cause undefined behavior. The standard defines empty iterator range in 24.1/7 and nowhere it says th ...
  • 看看std::sort引用,我们可以看到 取消引用的RandomIt类型必须满足MoveAssignable和MoveConstructible的要求。 因此,可复制( CopyConstructible或CopyAssignable )不在该算法的要求中。 这保证它不会尝试复制你的对象。 Looking at the std::sort reference, we see that The type of dereferenced RandomIt must meet the requirements o ...
  • typedef boost::counting_iterator counter; std::transform(counter(0), counter(N), A.begin(), myFunction1); std::transform(A.begin(), A.end(), counter(0), B.begin(), myFunction2); std::transform(A.begin(), A.end(), B.begin(), C.begin(), myFunction3); ...
  • 您不能将rotate与const_iterator一起使用,因为rotate更改指定范围的元素。 相反,你必须使用iterator 。 You can't use rotate with const_iterators, since rotate changes the elements of the range specified. Instead, you have to use iterators.
  • 这里的问题是比较运算符将iterator与iterator和const_iterator与const_iterator进行比较。 如果运算符是非成员函数,编译器将找到从iterator到const_iterator的转换并调用const_iterator比较函数。 如果比较运算符是成员函数,它将在lhs上调用,在示例中,它是iterator并且无法将const_iterator转换为iterator 。 解决方法的作用是将const_iterator为lhs,并且因为iterator可以转换为const_i ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)