date

Regex for validating date in dd-Mmm-yyyy format

[亡魂溺海] 提交于 2021-02-05 09:33:11
问题 I have an text input box which needs to be validated. The user should be only able to enter the date in dd-Mmm-yyyy format. ex: 01-Jun-2013, 31-Aug-2015 and so on. Or they should be able to enter T+1, T+2,...T+99. What kind of a regex pattern I could use to validate both of these. I think for validating the dd-Mmnm-yyyy, the following regex works: ^(([0-9])|([0-2][0-9])|([3][0-1]))\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\-\d{4}$ Please help me with this! Update: I just need the

Convert a column of dates from ordinal numbers to the standard date format - pandas

假装没事ソ 提交于 2021-02-05 09:29:17
问题 I have to convert a column of dates from the integer/date format to the date format d-m-Y. Example: import pandas as pd col1 = [737346, 737346, 737346, 737346, 737059, 737346] col2 = ['cod1', 'cod2', 'cod3', 'cod4', 'cod1', 'cod2'] dict = {'V1' : col1, 'V2' : col2} df = pd.DataFrame.from_dict(dict) df V1 V2 0 737346 cod1 1 737346 cod2 2 737346 cod3 3 737346 cod4 4 737059 cod1 5 737346 cod2 expected: df V1 V2 0 14-10-2019 cod1 1 14-10-2019 cod2 2 14-10-2019 cod3 3 14-10-2019 cod4 4 31-12-2018

I want to combine two variables into one with a date format

和自甴很熟 提交于 2021-02-05 08:44:26
问题 I have a data set with a character column for months ( MONTH ) and a numeric column indicating years ( YEAR ). In order to work with it as panel data, I need to unite these YEAR and MONTH into a variable with a date format. I have tried to change the variable MONTH to numeric format and then to merge MONTH with the column YEAR . R would not recognize it as a date variable. It currently looks like this: STATE MONTH YEAR VALUE California JAN 2018 800 California FEB 2018 780 California MAR 2018

How to make the View update instant in SwiftUI?

六月ゝ 毕业季﹏ 提交于 2021-02-05 08:38:07
问题 I have a Text that acts as a timer with different values of my array. And it displays with timerIntervalSinceNow . The problem is when it reaches zero it should show zero to but that does not happen before clicking again on the screen. If I do not click on it it keeps going up since it is timeIntervalSinceNow , but when I click it switches to the Text with 0 sec . Any way on telling SwiftUI to do this by itself without clicking? if(exerciseTime[value].timeIntervalSinceNow > 0) { Text

add time units to a date without timezone

佐手、 提交于 2021-02-05 08:36:06
问题 I write these in Linux bash date -d "2018-08-21 02:00:00" +'%y-%m-%d %T' and it prints 2018-08-21 02:00:00 But when I write these date -d "2018-08-21 02:00:00 +1 hour" +'%y-%m-%d %T' it prints 2018-08-21 07:30:00 instead of 2018-08-21 03:00:00 It adds my timezone to the date . How can I ignore timezone when I'm adding time units? 回答1: What is happening is that the +1 is interpreted as the timezone UTC+1h . So it will convert your input date from UTC+1 to your local time-zone and then still

Destructuring a function from object ( Date Object )

六眼飞鱼酱① 提交于 2021-02-05 08:25:07
问题 If i want to destruct an Object i would do : const obj = { a: 'a', fn: () => 'some function' } // const fn = obj.fn; // OR const { a, fn } = obj; console.log( fn() ); this doesn't work for the Date Object : Uncaught TypeError: this is not a Date object. const date = new Date(); const day = date.getDate(); console.log(day); // works const { getDate } = date; console.log( getDate() ); // doesn't work Why is this possible with the first Object and not with the Date ? how would one acheive that

Convert UTC date to current timezone

杀马特。学长 韩版系。学妹 提交于 2021-02-05 07:49:28
问题 I have to convert a UTC date in this format "2016-09-25 17:26:12" to the current time zone of Android. I did this: SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date myDate = simpleDateFormat.parse(temp.getString("date")); System.out.println(mydate.toString()); This works but I don't know why it print also "GMT+02:00". This is the Output: "Sun Sep 25 19:26:12 GMT+02:00 2016", I don't want to show

Strip out months from two date columns

為{幸葍}努か 提交于 2021-02-05 07:46:16
问题 I have a pandas dataframe that has contracts start and end date and a quantity. How would I strip out the individual months so they can be aggregated and graphed. ex Start Date End Date Demanded Customer 1/1/2017 3/31/2017 100 A 2/1/2017 3/31/2017 50 B strip out the months to the following Month Demand Customer 1/1/2017 100 A 2/1/2017 100 A 3/1/2017 100 A 2/1/2017 50 B 3/1/2017 50 B End result is to pivot this and then graph with months on the x-axis and total demand on the y-axis 回答1: You

PHP: get next date based on fixed base date

安稳与你 提交于 2021-02-05 07:44:28
问题 is there a way in PHP to get the next date(s) using a 4-week interval from a given date ? Example: My start date is Friday, Jan 03, 2014 and my interval is every 4 weeks from that date. What I am looking for is the next date (or dates, if possible) from the current date that matches this 4-week interval. In the above example this would be Friday, May 23, 2014 (then June 20, 2014, July 18, 2014 etc.). I know I can get the current date as follows: $today = date('Y-m-d'); and I could probably

java LocalDateTime parsing exception for date having pattern MM/d/yyyy HH:mm:ss a

孤街浪徒 提交于 2021-02-05 07:38:21
问题 I am getting exception while executing below code i am using java datetime APIs. String strDate = "12/4/2018 5:26:28 PM"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/d/yyyy HH:mm:ss a", Locale.ENGLISH); LocalDateTime localDateTime = LocalDateTime.parse(strDate, formatter); below exception is coming Exception in thread "main" java.time.format.DateTimeParseException: Text '12/4/2018 5:26:28 PM' could not be parsed at index 10 at java.time.format.DateTimeFormatter