Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7064561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:50:58+00:00 2026-05-28T04:50:58+00:00

Try the following in python 2.6: newyear_2012 = datetime.date.fromtimestamp(1325419200) newyear.year # returns 2012 newyear.isocalendar()

  • 0

Try the following in python 2.6:

newyear_2012 = datetime.date.fromtimestamp(1325419200)
newyear.year # returns 2012
newyear.isocalendar() # return (2011, 52, 7)

What’s the deal here? Is this a bug? I couldn’t find it documented, but maybe I didn’t look in the right place.

If I convert that unix timestamp here, it tells me: Sun, 01 Jan 2012 12:00:00 GMT

Update:
The answers below explain how this is not a python error but rather due to the ISO specification. If you want to get the week number that won’t ever put the first few days of the year in week #52, you can try the following:

week_no = int(time.strftime("%U", datetime_object.timetuple()))

I’m not sure what standard that’s corresponds to, but it behaves more intuitively from my perspective (in my application week numbers within a year should be ascending with time).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:50:59+00:00Added an answer on May 28, 2026 at 4:50 am

    From https://www.staff.science.uu.nl/~gent0113/calendar/isocalendar_text2.htm

    the first week of the ISO calendar year is the earliest week that contains at least four days of the month of January…(assumed to start on Monday)

    That makes ISO 2012 begin on Jan 2. Your timestamp is Sun, 01 Jan 2012 12:00:00 GMT

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
I have the following python code: try: pr.update() except ConfigurationException as e: returnString=e.line+' '+e.errormsg
A python newbie question: I need to do the following try: do-something() except error1:
Following script runs great: $ python myscript.py When I try to profile my code
Whenever I try the following in my python interpreter. I am able to copy
I have following code in a python script try: # send the query request
Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>
Try the following code: s = '#value#' puts s.gsub('#value#', Regexp.escape('*')) # => '\*' puts
I try the following code, but it doesn't work. [helloToolbar setBackgroundColor:[UIColor clearColor]];
When I try the following lookup in my code: Context initCtx = new InitialContext();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.