strptime

Compiler gets warnings when using strptime function (C)

一世执手 提交于 2019-12-10 03:18:58
问题 Typing man strptime it sais that this function needs to have declared _XOPEN_SOURCE and included time.h header. I did it. But, when I try to compile my code I get: ./check.c:56: warning: implicit declaration of function ‘strptime’ Look at my code: int lockExpired(const char *date, const char *format, time_t current) { struct tm *tmp = malloc(sizeof(struct tm *)); time_t lt; int et; strptime(date, format, tmp); lt = mktime(tmp); et = difftime(current, lt); if (et < 3600) return -et; return 1;

Colon in date format between seconds and milliseconds. How to parse in R?

风流意气都作罢 提交于 2019-12-08 16:10:08
问题 How can I parse this date format? Should I change this colon to dot or maybe someone know better solution? > x <- "2012.01.15 09:00:02:002" > strptime(x, "%Y.%m.%d %H:%M:%S:%OS") [1] "2012-01-15 09:00:02" > strptime(x, "%Y.%m.%d %H:%M:%OS") [1] "2012-01-15 09:00:02" > x <- "2012.01.15 09:00:02.002" > strptime(x, "%Y.%m.%d %H:%M:%OS") [1] "2012-01-15 09:00:02.001" 回答1: There's a subtle distinction here that may be throwing you off. As ?strptime notes: for 'strptime' '%OS' will input seconds

Not able to convert “00:30 AM” to 24 hours by strptime python

我是研究僧i 提交于 2019-12-08 10:21:46
问题 I am trying to convert "00:30 AM" to 24 hours time but it gives ValueError: time data '00:30 AM' does not match format '%I:%M %p' The code used is: datetime.datetime.strptime('00:30 AM','%I:%M %p') Can somebody please help me solving this error? 回答1: The %I format expects a number between one and twelve, not zero and twelve. A 12 hour clock always uses 12 for midnight or noon. From the strftime() documentation: %I Hour (12-hour clock) as a zero-padded decimal number. 01, 02, ..., 12 Either

Converting date formats python - Unusual date formats - Extract %Y%M%D

戏子无情 提交于 2019-12-07 22:17:45
问题 I have a large data set with a variety of Date information in the following formats: DAYS since Jan 1, 1900 - ex: 41213 - I believe these are from Excel http://www.kirix.com/stratablog/jd-edwards-date-conversions-cyyddd YYDayofyear - ex 2012265 I am familiar with python's time module, strptime() method, and strftime () method. However, I am not sure what these date formats above are called on if there is a python module I can use to convert these unusual date formats. Any idea how to get the

convert to date and strip time?

六眼飞鱼酱① 提交于 2019-12-07 08:12:36
问题 I have some data that looks like this: dates <- structure(c(1L, 2L, 4L, 3L), .Label = c("Sat, 18 Nov 2017 00:00:00 GMT", "Thu, 16 Nov 2017 00:00:00 GMT", "Tue, 14 Nov 2017 00:00:00 GMT", "Wed, 15 Nov 2017 00:00:00 GMT"), class = "factor") I would like to convert it to a date format instead of having it as a factor. Additionally, I want to strip the 00:00:00 GMT because it is meaningless I tried lubridate but I'm having troubles with the format: library(lubridate) mdy(dates) Warning message:

Is there a wildcard format directive for strptime?

放肆的年华 提交于 2019-12-07 05:17:39
问题 I'm using strptime like this: import time time.strptime("+10:00","+%H:%M") but "+10:00" could also be "-10:00" (timezone offset from UTC) which would break the above command. I could use time.strptime("+10:00"[1:],"%H:%M") but ideally I'd find it more readable to use a wildcard in front of the format code. Does such a wildcard operator exist for Python's strptime / strftime ? 回答1: There is no wildcard operator. The list of format directives supported by strptime is in the docs. What you're

using strptime converting string to time but getting garbage

亡梦爱人 提交于 2019-12-07 03:58:19
问题 I have a problem with using strptime() function in c++. I found a piece of code in stackoverflow like below and I want to store string time information on struct tm. Although I should get year information on my tm tm_year variable, I always get a garbage.Is there anyone to help me ? Thanks in advance. string s = dtime; struct tm timeDate; memset(&timeDate,0,sizeof(struct tm)); strptime(s.c_str(),"%Y-%m-%d %H:%M", &timeDate); cout<<timeDate.tm_year<<endl; // in the example below it gives me

Using strptime %z with special timezone format

一笑奈何 提交于 2019-12-06 23:31:47
问题 I am working with .csv data that was exported from Teradata. Several columns were originally timestamps with timezones, so after loading the .csv in R I'd like to convert these columns (which are loaded as strings) to POSIXlt or POSIXct. I am using strptime , but the format of the timezone from the .csv file does not match what strptime is expecting. For example, it expects -0400 but the .csv has the format -04:00 where a colon separates the hours and minutes. I can remove the colon, but this

R, strptime(), %b, trying to convert character to date format

故事扮演 提交于 2019-12-06 13:58:54
Hi i have some troubles concerning the strptime() function, i have character data like: data2[,1] 24-feb-15 26-ene-15 29-dic-14 i try to use srtptime() : strptime(data2[,1], "%d-%b-%y") but unfortunately it only works for 24-feb-15, i guess its because the other months are spanish abbreviated, so R doesn't recognize them, i have a lot of observations so i want to find a way to do it without changing manually the name of the months. Thanks for your help. JDaniel strptime will recognize abbreviated names in the current locale. You can change your current locale to spanish, transform your dates,

ValueError: time data '24:00' does not match format '%H:%M'

早过忘川 提交于 2019-12-06 11:21:34
I'm having serious trouble converting 24 hour time to 12 hour. def standard_time(t): t = datetime.strptime(t, "%H:%M") return t When fed in '24:00' we get ValueError: time data '24:00' does not match format '%H:%M' I also attempt converting using %I (12 hour) instead of %H, but get an error whenever hours go over 12: def standard_time(t): t = datetime.strptime(t, "%I:%M") return t Sort of stuck... ValueError: time data '13:30' does not match format '%I:%M' Does python have a simple 24 hour to 12 hour converter? Ideally 23:00 should put out 11:00 PM and 24:00 should not throw an error! You have