datetime

Javascript convert between timezones with momentjs

只谈情不闲聊 提交于 2021-02-07 08:38:52
问题 in my app the user selects a date + time, and a timezone. This choice must be shown to other users IN THEIR OWN timezone, which means if user A from New York chooses August 8, 3:00 AM in EDT, user B from Beijing will see this datetime converted to China Standard Time (CST). To do this I thought - ok I save user A's date and tell him to select out of 4 timezones. Server side I convert this from his EDT choice to UTC using moment timezone, and save it as UTC in the database, so that when I read

Bootstrap Datetimepicker set date

穿精又带淫゛_ 提交于 2021-02-07 06:51:39
问题 I am using a datetimepicker from Eonasdan which works fine so far. I have a HTML element like this <div id="datetimepicker"></div> and use the datetimepicker function like this: $("#datetimepicker").datetimepicker({ inline: true, sideBySide: true, stepping: 5, locale: "de" }); The result looks like this: I want to update the date via Javascript using the date function. My try looks like this: $("#datetimepicker").data("DateTimePicker").date("2016-01-01"); Unfortunately this only returns a

Passing datetime-like object to seaborn.lmplot

狂风中的少年 提交于 2021-02-07 06:51:17
问题 I am trying to do a plot of values over time using seaborn linear model plot but I get the error TypeError: invalid type promotion I have read that it is not possible to plot pandas date objects, but that seems really strange given seaborn requires you pass a pandas DataFrame to the plots. Below is a simple example. Does anyone know how I can get this to work? import pandas as pd import seaborn as sns; sns.set(color_codes=True) import matplotlib.pyplot as plt date = ['1975-12-03','2008-08-20'

Is “UTC” a valid timezone name for RFC 1123 specification?

你说的曾经没有我的故事 提交于 2021-02-07 06:33:43
问题 I am working against an API and it requests RFC 1123 dates. If I send requests with a date like Thu, 04 Sep 2014 06:42:22 UTC it gets rejected because of the "UTC" part. If I manipulate the string and make the timezone part "GMT" it works. I also noticed that many languages (Java, C#, Python) are formatting the UTC dates in RFC 1123 format with timezone string "GMT" however the language I'm using, Go, is keeping it as "UTC" . I'm trying to understand if it's a language bug or "UTC" should not

How to perform a cumulative sum of distinct values in pandas dataframe

China☆狼群 提交于 2021-02-07 06:01:50
问题 I have a dataframe like this: id date company ...... 123 2019-01-01 A 224 2019-01-01 B 345 2019-01-01 B 987 2019-01-03 C 334 2019-01-03 C 908 2019-01-04 C 765 2019-01-04 A 554 2019-01-05 A 482 2019-01-05 D and I want to get the cumulative number of unique values over time for the 'company' column. So if a company appears at a later date they are not counted again. My expected output is: date cumulative_count 2019-01-01 2 2019-01-03 3 2019-01-04 3 2019-01-05 4 I've tried: df.groupby(['date'])

How to perform a cumulative sum of distinct values in pandas dataframe

我只是一个虾纸丫 提交于 2021-02-07 06:01:06
问题 I have a dataframe like this: id date company ...... 123 2019-01-01 A 224 2019-01-01 B 345 2019-01-01 B 987 2019-01-03 C 334 2019-01-03 C 908 2019-01-04 C 765 2019-01-04 A 554 2019-01-05 A 482 2019-01-05 D and I want to get the cumulative number of unique values over time for the 'company' column. So if a company appears at a later date they are not counted again. My expected output is: date cumulative_count 2019-01-01 2 2019-01-03 3 2019-01-04 3 2019-01-05 4 I've tried: df.groupby(['date'])

How to find the difference of two timestamps in java?

邮差的信 提交于 2021-02-07 05:54:47
问题 I have an ArrayList including several number of time-stamps and the aim is finding the difference of the first and the last elements of the ArrayList . String a = ArrayList.get(0); String b = ArrayList.get(ArrayList.size()-1); long diff = b.getTime() - a.getTime(); I also converted the types to int but still it gives me an error The method getTime is undefined for the type String . Additional info : I have a class A which includes String timeStamp = new SimpleDateFormat("ss S").format(new

Pandas: conditional shift

断了今生、忘了曾经 提交于 2021-02-07 04:59:43
问题 There is a way to shift a dataframe column dependently on the condition on two other columns? something like: df["cumulated_closed_value"] = df.groupby("user").['close_cumsum'].shiftWhile(df['close_time']>df['open_time]) I have figured out a way to do this but it's inefficient: 1)Load data and create the column to shift df=pd.read_csv('data.csv') df.sort_values(['user','close_time'],inplace=True) df['close_cumsum']=df.groupby('user')['value'].cumsum() df.sort_values(['user','open_time']

How to check if datetime is older than 20 seconds

和自甴很熟 提交于 2021-02-07 04:42:05
问题 This is my first time here so I hope I post this question at the right place. :) I need to build flood control for my script but I'm not good at all this datetime to time conversions with UTC and stuff. I hope you can help me out. I'm using the Google App Engine with Python. I've got a datetimeproperty at the DataStore database which should be checked if it's older than 20 seconds, then proceed. Could anybody help me out? So in semi-psuedo: q = db.GqlQuery("SELECT * FROM Kudo WHERE fromuser =

datetime.strptime(‘2017-01-12T14:12:06.000-0500’,'%Y-%m-%dT%H:%M:%S.%f%Z')

怎甘沉沦 提交于 2021-02-07 03:54:08
问题 I've been trying to convert this specific date format to a string in Python like so: datetime.strptime(‘2017-01-12T14:12:06.000-0500’,'%Y-%m-%dT%H:%M:%S.%f%Z') But it doesn't work. What am I doing wrong? 回答1: Solution for Python 2.7 From the comments it became clear that OP needs a solution for Python 2.7. Apparently, there's no %z in strptime for python 2.7 even though the documentation claims the contrary, the raised error is ValueError: 'z' is a bad directive in format '%Y-%m-%dT%H:%M:%S