Comments (8)
Please fix the documentation to not hate on Python datetime objects because of a misunderstanding.
My recommendation would be to update the documentation to provide an example of how to add timezone information, either with pytz
, the datetime
library itself, or (preferably) both. It's not terribly hard and a little Google search should help you find how to do that appropriately.
from analytics-python.
They don't "lose timezone information", whatever that means. You're not giving timezone information to the now() function in the first place. Try this: datetime.datetime.now(tz=pytz.utc).
Of note, in Python 3 the maintainers added a UTC instance to the standard library (so you don't need pytz just to get UTC zoned datetimes), and support for fixed-offset timezones. This support has also been added to strptime, so if you parse a datetime string with a fixed-time offset and the %z
operator you'll get a zoned datetime (in Python 2, %z
in strptime is an error):
>>> datetime.strptime("2015-03-15T07:54:13-1045", "%Y-%m-%dT%H:%M:%S%z")
datetime.datetime(2015, 3, 15, 7, 54, 13, tzinfo=datetime.timezone(datetime.timedelta(-1, 47700)))
You still have to use pytz for "named" timezones.
from analytics-python.
Or really, just use arrow, which abstract all that stuff, and let you go from and to datetime when you need it.
from analytics-python.
Or really, just use arrow, which abstract all that stuff, and let you go from and to datetime when you need it.
Except that's not really what arrow does, it mostly asserts that there's no such thing as a date, a time, or a naive datetime (then adds a bunch of utility methods and handrolls localisation and formatting because apparently the CLDR still isn't a thing)
from analytics-python.
Thanks @dwieeb. Completely agree; point well made and very appreciated. @jgershen to accompany your release this sprint, would you mind updating the docs to reflect the proper approach and remove disparaging/embarrassing language? (And close this once it's done?) Thanks!
from analytics-python.
Yep, the stuff we had there sure is incorrect & embarrassing; I'll fix the docs. Thanks @dwieeb for bringing it to our attention!
from analytics-python.
Updated to remove the wrong language and add a brief description of how naive / aware objects work.
from analytics-python.
👍
Thanks, this is great!
from analytics-python.
Related Issues (20)
- Change in date format for originalTimestamp HOT 1
- Import analytics clash with standard library module HOT 3
- `import analytics` broken in 2.2.1 HOT 1
- Documentation site is outdated and not aligned with the latest README HOT 1
- Invalid base class for APIError
- Incorrect SQL test generated from Parameter with default_value HOT 4
- The lib analytics in Databricks not delivery 100% of calls HOT 7
- Issue: Messages are getting dropped sometimes and not pushed to segment. HOT 2
- Deprecate unmaintained PyPI package HOT 2
- Convert to Github Actions
- Python 3.10 and 3.11 support HOT 5
- [FEATURE REQUEST] | Context information with `track` calls HOT 1
- Successive track calls don't get logged to app.segment.com sources (Debugger)
- No Data Flowing After Upgrading to Python 3.11 HOT 1
- PyPI wheel contains old analytics package HOT 2
- Resolve Test Issues
- Version 2.3.0 missing jwt as an explicit dependency HOT 4
- Basic auth was removed from the auth methods in v2.3 HOT 1
- Segment integration with Gainsight not working from Python HOT 3
- Test issue please ignore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from analytics-python.