strftime

Solaris timezone in C (missing %z on strftime)

蹲街弑〆低调 提交于 2019-12-24 08:24:19
问题 I have an application that writes to another application and needs to provide the date + timezone of the system. I have been using strftime with the %z argument to get the timezone, and it has been working very well on Linux. However, last week we decided to merge it to solaris just to find out that %z is not present. Someone suggested to use %Z , which will give the timezone name, but I need the %z which gives the timezone with the offset format, like +0100 or -0300 . Anyone has ideas? 回答1:

ISO 8601 week number in C

徘徊边缘 提交于 2019-12-24 02:14:25
问题 I am trying to get the ISO8601 week number with C. MinGW is installed on my PC. GCC version is 5.3.0. You can see my code below. strftime doesn't work for specifier "%V". But it works fine with the specifier "%W". But that's not what I want. I need the week number of year in ISO 8601 format. I have tried my code with 2 different online C compilers and they both worked fine. I doubt that the compiler on my PC is not well configured. Can anyone tell me what am I doing wrong? Any help would be

Getting Abbreviated timezone using strftime() using C

可紊 提交于 2019-12-23 15:12:59
问题 I have viewed this , and this , on SO, but they deal with non-C variations of the same problem. Using GNU GCC compiler (Code::Blocks, in Windows) with the following code: int main(void) { time_t rawtime; struct tm *info; char timeStr[80]; time( &rawtime ); info = localtime( &rawtime ); strftime(timeStr,80,"%a %b %d %H:%M:%S %Z %Y", info); printf("%s", timeStr); getchar(); return 0; } I am getting this time string: Tue Aug 30 14:55:08 Pacific Daylight Time 2016 Everything is fine except time

DateTime::format and strftime

末鹿安然 提交于 2019-12-22 10:40:02
问题 I have $date = $run['at']; which gives me 2013-06-03T16:52:24Z (from a JSON input). To transform it to get for example " d M Y, H:i " I use $date = new DateTime($run['at']); echo $date->format('d M Y, H:i'); Problem is I need the date in italian. And the only function that supports set_locale is strftime . How can I "wrap" DateTime::format with strftime (or replace, dunno)? 回答1: setlocale(LC_TIME, 'it_IT.UTF-8'); $date = new DateTime($run['at']); strftime("%d %B", $date->getTimestamp()) ...

Convert NSDate to String with strftime

让人想犯罪 __ 提交于 2019-12-22 05:42:14
问题 How would I convert an NSDate to a NSString, formatted with strftime specifiers? 回答1: you could use strftime. NSDate *date = [NSDate date]; time_t time = [date timeIntervalSince1970]; struct tm timeStruct; localtime_r(&time, &timeStruct); char buffer[80]; strftime(buffer, 80, "%d.%m.%Y %H:%M:%S", &timeStruct); NSString *dateStr = [NSString stringWithCString:buffer encoding:NSASCIIStringEncoding]; I hope it's correct. 回答2: You'll need an NSDateFormatter , using setDateFormat: . Here's the

Rails undefined method `strftime' for “2013-03-06”:String

ε祈祈猫儿з 提交于 2019-12-22 04:38:25
问题 I am getting the error undefined method `strftime' for "2013-03-06":String when trying to display a date normally (June Sunday 3, 2013 or something similar) from the string 2013-03-06 using strftime. The line that does this in my index.html.erb and looks like this <td><%= task.duedate.strftime("%B %e, %Y") %></td> I am just learning Rails so I am sure it is just a stupid beginners error, any help would be appreciated. Thank you 回答1: It looks like your duedate is a string, when strftime is a

SQLite 日期 & 时间

烂漫一生 提交于 2019-12-21 04:29:19
SQLite 日期 & 时间 SQLite 支持以下五个日期和时间函数: 序号 函数 实例 1 date(timestring, modifiers...) 以 YYYY-MM-DD 格式返回日期。 2 time(timestring, modifiers...) 以 HH:MM:SS 格式返回时间。 3 datetime(timestring, modifiers...) 以 YYYY-MM-DD HH:MM:SS 格式返回。 4 julianday(timestring, modifiers...) 这将返回从格林尼治时间的公元前 4714 年 11 月 24 日正午算起的天数。 5 strftime(timestring, modifiers...) 这将根据第一个参数指定的格式字符串返回格式化的日期。具体格式见下边讲解。 g, modifiers...) 这将根据第一个参数指定的格式字符串返回格式化的日期。具体格式见下边讲解。 上述五个日期和时间函数把时间字符串作为参数。时间字符串后跟零个或多个 modifiers 修饰符。strftime() 函数也可以把格式字符串作为其第一个参数。下面将为您详细讲解不同类型的时间字符串和修饰符。 时间字符串 一个时间字符串可以采用下面任何一种格式: 序号 时间字符串 实例 1 YYYY-MM-DD 2010-12-30 2 YYYY

python 获取日期和时间

独自空忆成欢 提交于 2019-12-20 11:46:17
总结了最近学习到的time的几种方法,归纳在这里。 python 中 time 有三种格式: float , struct tuple (time.struct_time 或 datetime.datetime), str 常用的: float --> struct tuple : time. localtime ( float ) struct time tuple --> str : time. strftime (format, struct time tuple ) str --> struct time tuple : time. strptime (str, format) struct time tuple --> float : time. mktime (struct time tuple) struct time tuple --> datetime: datetime(*time_tuple[0:6]) float --> datetime : datetime.datetime. fromtimestamp ( float ) datetime --> str : datetime .strftime (format, datetime ) str --> datetime : datetime.strptime (str, format) datetime

python的datetime模块实用小记

偶尔善良 提交于 2019-12-19 19:07:36
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 今天简单整理一下python的datetime模块使用中遇到的方法,感觉这个模块相当灵活, 实现相同的需求可以用多种方法解决。 所以我也不多描述和讲解这个模块的具体内容了, 仅作为记录和索引。 参考资料: https://docs.python.org/2/library/datetime.html 主要类: datetime: https://docs.python.org/2/library/datetime.html#datetime-objects timedelta: https://docs.python.org/2/library/datetime.html#timedelta-objects date: https://docs.python.org/2/library/datetime.html#date-objects time: https://docs.python.org/2/library/datetime.html#time-objects 0. 导入模块 import datetime 1. 获取当前时间,以"年-月-日"格式显示 >>> datetime.datetime.now().strftime("%Y-%m-%d") '2015-08-25' >>> datetime

8道Python基础面试练习题

ⅰ亾dé卋堺 提交于 2019-12-18 21:33:08
1.26个字母大小写成对打印,例如:Aa,Bb...... for i in range(26): print(chr(65+i)+chr(97+i)) 2.一个list包含10个数字,然后生成一个新的list,要求新的list里面的数都比之前的数多1 ''' 遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333 寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书! ''' list=[2,3,6,4,7,5,1,8,9,0] list1=[] for i in list: list1.append(i+1) print(list1) 3.倒序取出每个单词的第一个字母,例如:I am a good boy! 方法1 tre='I am a good boy!' t=tre.split() #print(t) t.reverse() list=[] #print(t) for i in t: list.append(i[0]) print(list) 方法2 ''' 遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333 寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书! ''' a = "I AM A BOY" result = [] for i in a.split()[::-1]