草庐IT

dateFormatter3

全部标签

ios - DateFormatter localizedString - 只有日和月,没有年

这个问题在这里已经有了答案:NSDateFormatter:DateaccordingtocurrentLocale,withoutYear(4个答案)关闭5年前。是否可以从只有月和日的日期中获取本地化字符串?letlocalizedDate=DateFormatter.localizedString(from:date,dateStyle:.medium,timeStyle:.none)这将打印2017年9月15日或2017年9月15日。我想遵循用户的日期格式,不显示年,只显示月和日。我的意思是Sept15或15Sep。可能吗?

python - 为什么在使用 matplotlib 的 DateFormatter 格式化 x 轴上的日期时会出现 "python int too large to convert to C long"错误?

正在关注thisanswer'suseofDateFormatter,我尝试使用pandas0.15.0和matplotlib1.4.2绘制时间序列并用年份标记其x轴:importdatetimeasdtimportmatplotlibasmplimportmatplotlib.pyplotaspltimportpandas.io.dataaspdioimportscipyasspt1=dt.datetime(1960,1,1)t2=dt.datetime(2014,6,1)data=pdio.DataReader("GS10","fred",t1,t2).resample("Q",h

ios - 来自字符串的 DateFormatter 日期返回 nil

由于某些原因,某些设备无法将字符串转换为日期。这是我的日期转换代码:funcdateFromString(string:String)->Date?{letf=DateFormatter.init()f.dateFormat="yyyy-MM-ddHH:mm:ss"returnf.date(from:string)}现在,通过我的分析平台,我可以捕捉到返回nil的时间。我不知道为什么会这样。我认为它与本地,可能与时区或12/24h设置有关,但我不知道是什么问题。更多详情...我已经跟踪到以下导致零返回的设置:timezone-Asia/Muscatlocal-en_GBstring-"

ios - DateFormatter 不返回 "HH:mm:ss"的日期

代码摘录如下:funcmapping(map:Map){time(fromJSON:{letdateFormatter=DateFormatter()dateFormatter.dateFormat="HH:mm:ss"//dateFormatter.timeZone=TimeZone(abbreviation:"EEST")ifletargument=$0{letdate=dateFormatter.date(from:argument)returndateFormatter.date(from:argument)}returnnil}}$0是带有"22:12:00"的字符串。我输入

ios - DateFormatter 在 Swift 中为没有时间的特定日期字符串返回 nil

我真的不明白这段代码发生了什么,我正在尝试将字符串转换为日期。我不明白的是转换适用于大多数日期,但不适用于仅2个日期。letdateFormatter=NSDateFormatter()dateFormatter.locale=NSLocale(localeIdentifier:"es")dateFormatter.dateFormat="dd'de'MMMM"dateFormatter.dateFromString("1deoctubre")dateFormatter.dateFromString("2deoctubre")dateFormatter.dateFromString("