René's URL Explorer Experiment


Title: Storage: mtime of downloaded file is incorrect by UTC offset · Issue #4 · googleapis/python-storage · GitHub

Open Graph Title: Storage: mtime of downloaded file is incorrect by UTC offset · Issue #4 · googleapis/python-storage

X Title: Storage: mtime of downloaded file is incorrect by UTC offset · Issue #4 · googleapis/python-storage

Description: Google Cloud Storage v1.25.0 Python 3.7.3 OS: OSX & Win7 Issue: If I upload a file to Google Cloud Storage and then immediately download it, the mtime is incorrect - for me, I'm in EST, so I'm 5 hours behind UTC. That's the exact timedel...

Open Graph Description: Google Cloud Storage v1.25.0 Python 3.7.3 OS: OSX & Win7 Issue: If I upload a file to Google Cloud Storage and then immediately download it, the mtime is incorrect - for me, I'm in EST, so I'm 5 ho...

X Description: Google Cloud Storage v1.25.0 Python 3.7.3 OS: OSX & Win7 Issue: If I upload a file to Google Cloud Storage and then immediately download it, the mtime is incorrect - for me, I'm in EST, so ...

Opengraph URL: https://github.com/googleapis/python-storage/issues/4

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Storage: mtime of downloaded file is incorrect by UTC offset","articleBody":"Google Cloud Storage v1.25.0\r\nPython 3.7.3\r\nOS: OSX \u0026 Win7\r\n\r\nIssue: If I upload a file to Google Cloud Storage and then immediately download it, the mtime is incorrect - for me, I'm in EST, so I'm 5 hours behind UTC.  That's the exact timedelta that occurs between the file's original mtime and the recorded mtime after the file is downloaded.\r\n\r\nHere's an example screenshot:\r\n![Screen Shot 2020-01-27 at 9 35 52 PM](https://user-images.githubusercontent.com/26491362/73231091-5a360b80-414d-11ea-9001-695bc0757061.png)\r\nThe original file mtime in Google Cloud Storage is 1/23/20 9:04 PM (which is correct from the file I uploaded), but when I download the file, the mtime becomes 1/24/20 2:04 AM, which is 5 hours ahead of what is supposed to be (the UTC offset from my timezone).\r\n\r\nThe issue is here in `blob.download_to_filename`:\r\n```\r\nupdated = self.updated\r\nif updated is not None:\r\n            mtime = time.mktime(updated.timetuple())\r\n            os.utime(file_obj.name, (mtime, mtime))\r\n```\r\nIn my example, `updated` is the timezone-aware datetime corresponding to `2020-01-24 02:04:11.184000+00:00` (it has `tzinfo==UTC`).  The `updated.timetuple()` is\r\n```\r\ntime.struct_time(tm_year=2020, tm_mon=1, tm_mday=24, tm_hour=2, tm_min=4, tm_sec=9, tm_wday=4, tm_yday=24, tm_isdst=0)\r\n```\r\n\r\nThe problem, I believe, is that the timetuple doesn't know this is a UTC date, nor did it convert to my timezone.  The docs of `mktime` note, \"Its argument is the struct_time or full 9-tuple (since the dst flag is needed; use -1 as the dst flag if it is unknown) which expresses the time in local time, not UTC.\"  Perhaps, we should do this instead:\r\n```\r\nif updated is not None:\r\n   mtime = updated.timestamp() # For Python3, not sure of the Python2 version\r\n   os.utime(file_obj.name, (mtime, mtime))\r\n```\r\n\r\nThe `timestamp()` function accounts for the timezone information in the datetime object.\r\nI've just been doing this manually in my code after downloading a file because my application is sensitive to mtimes, and it seems to fix the issue.","author":{"url":"https://github.com/mcsimps2","@type":"Person","name":"mcsimps2"},"datePublished":"2020-01-28T02:54:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/4/python-storage/issues/4"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:bcf33e0b-cb64-1beb-4e41-515b9757ac5c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE032:69662:213A714:2D9D7FB:6A4ED81D
html-safe-noncec69b6406127ebff5ad831d47491052313446849de84892c3ea724fec8498094b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDMyOjY5NjYyOjIxM0E3MTQ6MkQ5RDdGQjo2QTRFRDgxRCIsInZpc2l0b3JfaWQiOiI1NzYwNzc0NjY5MTA1MTMxODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac220282589138d1a4def4410302ee21eb595e60683c4e1c8167eae805574720fc
hovercard-subject-tagissue:558423137
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-storage/4/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3271766e66439a65353aa00b67586be1fc0eea7334e03741208aa7ea305bbae3/googleapis/python-storage/issues/4
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3271766e66439a65353aa00b67586be1fc0eea7334e03741208aa7ea305bbae3/googleapis/python-storage/issues/4
og:image:altGoogle Cloud Storage v1.25.0 Python 3.7.3 OS: OSX & Win7 Issue: If I upload a file to Google Cloud Storage and then immediately download it, the mtime is incorrect - for me, I'm in EST, so I'm 5 ho...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemcsimps2
hostnamegithub.com
expected-hostnamegithub.com
None41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c
turbo-cache-controlno-preview
go-importgithub.com/googleapis/python-storage git https://github.com/googleapis/python-storage.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992639
octolytics-dimension-repository_nwogoogleapis/python-storage
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992639
octolytics-dimension-repository_network_root_nwogoogleapis/python-storage
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec37fe3e3f5f306900bd5b6bee97463f66c938b2c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-storage/issues/4#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-storage%2Fissues%2F4
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-storage%2Fissues%2F4
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fpython-storage
Reloadhttps://github.com/googleapis/python-storage/issues/4
Reloadhttps://github.com/googleapis/python-storage/issues/4
Reloadhttps://github.com/googleapis/python-storage/issues/4
Please reload this pagehttps://github.com/googleapis/python-storage/issues/4
googleapis https://github.com/googleapis
python-storagehttps://github.com/googleapis/python-storage
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-storage
Fork 172 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-storage
Star 502 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-storage
Code https://github.com/googleapis/python-storage
Issues 0 https://github.com/googleapis/python-storage/issues
Pull requests 0 https://github.com/googleapis/python-storage/pulls
Actions https://github.com/googleapis/python-storage/actions
Projects https://github.com/googleapis/python-storage/projects
Security and quality 0 https://github.com/googleapis/python-storage/security
Insights https://github.com/googleapis/python-storage/pulse
Code https://github.com/googleapis/python-storage
Issues https://github.com/googleapis/python-storage/issues
Pull requests https://github.com/googleapis/python-storage/pulls
Actions https://github.com/googleapis/python-storage/actions
Projects https://github.com/googleapis/python-storage/projects
Security and quality https://github.com/googleapis/python-storage/security
Insights https://github.com/googleapis/python-storage/pulse
#42https://github.com/googleapis/python-storage/pull/42
Storage: mtime of downloaded file is incorrect by UTC offsethttps://github.com/googleapis/python-storage/issues/4#top
#42https://github.com/googleapis/python-storage/pull/42
https://github.com/HemangChothani
api: storageIssues related to the googleapis/python-storage API.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22api%3A%20storage%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/mcsimps2
mcsimps2https://github.com/mcsimps2
on Jan 28, 2020https://github.com/googleapis/python-storage/issues/4#issue-558423137
https://user-images.githubusercontent.com/26491362/73231091-5a360b80-414d-11ea-9001-695bc0757061.png
HemangChothanihttps://github.com/HemangChothani
api: storageIssues related to the googleapis/python-storage API.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22api%3A%20storage%22
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-storage/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.