datetime-format

Showing correct sunrise/sunset times using unix timestamp

时光总嘲笑我的痴心妄想 提交于 2020-06-05 12:05:17
问题 I'm getting a UNIX timestamp from DarkSkyApi for the sunrise & sunset times for the selected location and i want to convert it to a DateTime format and display it to the user. I want the time values to be local. Example case : The user is in Italy and selects "Tokyo, JP" as the desired location to fetch weather info for. The sunrise & sunset time values should be formatted & shown as local times. So for Tokyo, sunrise should be something around 4:34 AM & 18:36 PM for sunset. With what i have

Showing correct sunrise/sunset times using unix timestamp

房东的猫 提交于 2020-06-05 12:04:05
问题 I'm getting a UNIX timestamp from DarkSkyApi for the sunrise & sunset times for the selected location and i want to convert it to a DateTime format and display it to the user. I want the time values to be local. Example case : The user is in Italy and selects "Tokyo, JP" as the desired location to fetch weather info for. The sunrise & sunset time values should be formatted & shown as local times. So for Tokyo, sunrise should be something around 4:34 AM & 18:36 PM for sunset. With what i have

Change to a 24 hour format for datetime data in Google Charts

故事扮演 提交于 2020-05-25 06:48:26
问题 Im plotting data with javascript using the Google Charts API. The default format for datetime data view is the 12 hour am/pm format. How can I change the view to show a 24 hour format? An example of code is shown below, where the default datetime format is used: var price_data = new google.visualization.DataTable(); price_data.addColumn('datetime','Time'); price_data.addColumn('number','Price [øre/KWh]'); price_data.add_row([new Date(2013,23,3,4,5),3]) price_data.add_row([new Date(2013,1,5,4

Java DateTimeFormatterBuilder with optional pattern results in DateTimeParseException

我是研究僧i 提交于 2020-05-23 13:19:47
问题 Goal Provide a flexible parser for LocalDate instances that can handle input in one of the following formats: yyyy yyyyMM yyyyMMdd Implementation Attempt The following class attempts to handle both the first and the second pattern. Parsing works for the year input, but year + month results in the exception outlined below. import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class

Java DateTimeFormatterBuilder with optional pattern results in DateTimeParseException

China☆狼群 提交于 2020-05-23 13:18:10
问题 Goal Provide a flexible parser for LocalDate instances that can handle input in one of the following formats: yyyy yyyyMM yyyyMMdd Implementation Attempt The following class attempts to handle both the first and the second pattern. Parsing works for the year input, but year + month results in the exception outlined below. import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class

Convert a string to ZonedDateTime

空扰寡人 提交于 2020-05-17 07:44:15
问题 I need to convert the string 2020-04-15T23:00:00+0000 to a ZonedDateTime. I tried the below but they didnt work: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss Z"); System.out.println(ZonedDateTime.parse("2020-04-15T23:00:00+0000", formatter)); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss 00:00"); System.out.println(ZonedDateTime.parse("2020-04-15T23:00:00+0000", formatter)); DateTimeFormatter formatter = DateTimeFormatter

C# Object containing datetime and specific cultureinfo to be fully compatible with Excel datetime cell

主宰稳场 提交于 2020-05-17 05:46:13
问题 As I am trying to import excel file into C# object, I notice that so far the only way to create a dateTime type including the specific cultureinfo and the datetimeformat of the specific cell is converting into string. For example, it can be instantiated: var date = new DateTime(DateTime.Now.Ticks, DateTimeKind.Unspecified); var culturedDateString = date.ToString(specifiedCulture); But I have not seen any c# object that can contain both datetime value as well as the specific cultureInfo and

DateTimeParseException: Text could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor

拥有回忆 提交于 2020-05-10 09:55:24
问题 LocalDateTime.parse("2017-02-02 08:59:12", DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss")); It prints error: java.time.format.DateTimeParseException: Text '2017-02-02 08:59:12' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {MinuteOfHour=59, NanoOfSecond=0, SecondOfMinute=12, MicroOfSecond=0, MilliOfSecond=0, HourOfAmPm=8},ISO resolved to 2017-02-02 of type java.time.format.Parsed Accoeding message looks like all values parsed correct, but anyway I see error.

Pandas to_datetime changes year unexpectedly

安稳与你 提交于 2020-04-16 03:08:12
问题 I have a date column which after using pandas read_csv is represented as the object type. I'm trying to convert it to pandas datetime object but when using pd.to_datetime() it returns incorrect datetime object. for example, I have dates in this format 01-06-68 , where 01 is the day, 06 is the month and 68 is the year. Applying pandas to_datetime() to this string returns 2068-06-01 but should return 1968-06-01 , where 06 is a month and 01 is the day. I tried every possible solution using

pandas format datetimeindex to quarters

混江龙づ霸主 提交于 2020-04-13 17:15:00
问题 With a resample job, I have my monthly values converted to quarterly values: hs=hs.resample('QS',axis=1).mean() Works well, my columns look like this: hs.columns: DatetimeIndex(['2000-01-01', '2000-04-01', '2000-07-01', '2000-10-01', '2001-01-01', '2001-04-01', '2001-07-01', '2001-10-01', '2002-01-01', '2002-04-01', '2002-07-01', '2002-10-01', Now I want them to convert in the YYYYq[1-4] format, which I thought should be as easy as (according to this Link): hs.columns.strftime('%Yq%q') But