datetime

How to convert an ambiguous datetime column in data.table without using strptime?

ぃ、小莉子 提交于 2021-02-19 02:18:12
问题 My data.table has a column with an "ambiguous" datetime format: "12/1/2016 15:30". How can I convert this datetime to a format R recognizes in a data.table without using strptime() and getting the warning message for initially converting to POSIXlt. The process works but the warning makes me think there is another way. My data table: my_dates <- c("12/1/2016 15:30", "12/1/2016 15:31", "12/1/2016 15:32") this <- c("a", "b", "c") that <- c(1, 2, 3) my_table <- data.table(my_dates, this, that)

pandas datetime set Sunday as first day of the week

拟墨画扇 提交于 2021-02-19 02:16:45
问题 I've got a dataframe of pandas with a series of dates (all Sundays) like this: Date Year Week 2011-01-02 2011 52 2011-01-23 2011 3 2011-01-23 2011 3 2011-01-30 2011 4 2011-01-30 2011 4 The week is given by df['Date'].dt.week , and what I want is set Sundays as the first day of the week, so I can get: Date Year Week 2011-01-02 2011 1 2011-01-23 2011 4 2011-01-23 2011 4 2011-01-30 2011 5 2011-01-30 2011 5 How can I do that in the simplest way? P.S. I have failed to mention that there're

pandas datetime set Sunday as first day of the week

大憨熊 提交于 2021-02-19 02:16:41
问题 I've got a dataframe of pandas with a series of dates (all Sundays) like this: Date Year Week 2011-01-02 2011 52 2011-01-23 2011 3 2011-01-23 2011 3 2011-01-30 2011 4 2011-01-30 2011 4 The week is given by df['Date'].dt.week , and what I want is set Sundays as the first day of the week, so I can get: Date Year Week 2011-01-02 2011 1 2011-01-23 2011 4 2011-01-23 2011 4 2011-01-30 2011 5 2011-01-30 2011 5 How can I do that in the simplest way? P.S. I have failed to mention that there're

How to convert an ambiguous datetime column in data.table without using strptime?

左心房为你撑大大i 提交于 2021-02-19 02:15:04
问题 My data.table has a column with an "ambiguous" datetime format: "12/1/2016 15:30". How can I convert this datetime to a format R recognizes in a data.table without using strptime() and getting the warning message for initially converting to POSIXlt. The process works but the warning makes me think there is another way. My data table: my_dates <- c("12/1/2016 15:30", "12/1/2016 15:31", "12/1/2016 15:32") this <- c("a", "b", "c") that <- c(1, 2, 3) my_table <- data.table(my_dates, this, that)

DateTimeFormatter giving wrong format for edge cases [duplicate]

只愿长相守 提交于 2021-02-19 01:11:50
问题 This question already has answers here : Java LocalDate Formatting of 2000-1-2 error [duplicate] (2 answers) Closed 2 years ago . DateTimeFormatter is not giving correct format for Dec 30 and 31 2018 as per following snippet. final String DATE_FORMAT = "YYYYMM"; DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(DATE_FORMAT); LocalDateTime startDate = LocalDateTime.of(2018,12,29,5,0,0); System.out.println(startDate.format(dateFormat)); //prints 201812 LocalDateTime startDate =

How to Parse Date Strings with 🎌 Japanese Numbers in Java DateTime API

末鹿安然 提交于 2021-02-18 22:10:28
问题 After asking [How to parse 🎌 Japanese Era Date string values into LocalDate & LocalDateTime], I was curious about the following case; 明治二十三年十一月二十九日 Is there a way to parse Japanese numbers on top of Japanese Calendar characters, essentially a pure Japanese date, into LocalDate ? Using only Java DateTime API. I don't want to modify the input String values, but want just API to handle the recognition. 回答1: For anyone reading along, your example date string holds an era designator, year of era

How to Parse Date Strings with 🎌 Japanese Numbers in Java DateTime API

笑着哭i 提交于 2021-02-18 22:09:13
问题 After asking [How to parse 🎌 Japanese Era Date string values into LocalDate & LocalDateTime], I was curious about the following case; 明治二十三年十一月二十九日 Is there a way to parse Japanese numbers on top of Japanese Calendar characters, essentially a pure Japanese date, into LocalDate ? Using only Java DateTime API. I don't want to modify the input String values, but want just API to handle the recognition. 回答1: For anyone reading along, your example date string holds an era designator, year of era

Django template datetime.weekday name

时光毁灭记忆、已成空白 提交于 2021-02-18 22:00:59
问题 Is there a way to display the weekday of a datetime object in a template as the actual name of the weekday? Basically I want it to print Friday instead of 5 . 回答1: See the documentation for the built-in date filter. From there you'll see you need to use: l Day of the week, textual, long. 'Friday' 回答2: For clarity's sake, the template tag format character "l" (lower-case "L") can be used in the Django template like so: {{ object.some_date_field | date:"l" }} Django 1.8.2 回答3: You can also use:

Django template datetime.weekday name

时光总嘲笑我的痴心妄想 提交于 2021-02-18 21:58:22
问题 Is there a way to display the weekday of a datetime object in a template as the actual name of the weekday? Basically I want it to print Friday instead of 5 . 回答1: See the documentation for the built-in date filter. From there you'll see you need to use: l Day of the week, textual, long. 'Friday' 回答2: For clarity's sake, the template tag format character "l" (lower-case "L") can be used in the Django template like so: {{ object.some_date_field | date:"l" }} Django 1.8.2 回答3: You can also use:

What does python return on the leap second

為{幸葍}努か 提交于 2021-02-18 20:56:23
问题 What does python time and datetime module return on the leap second? What will I get when we are at 23:59:60.5 if I call: time.time() datetime.datetime.utcnow() datetime.datetime.now(pytz.utc) Also, any difference between py2.7 and py3? Why it is confusing (at least for me): From the datetime docs I see: Unlike the time module, the datetime module does not support leap seconds. On the time docs I see there is "support" for leap seconds when parsing with strptime . But there is no comment