New research suggests we do find humor in tragedy, but only during a specific, limited window of time.

Did you hear the one about Hurricane Sandy? Did you find it hilarious? Tasteless? Or just lame?

Newly published research concludes the answer depends in part on exactly when the joke reached your ear, or inbox.

An analysis of responses to humorous quips referencing last year’s devastating storm suggests the adage that “comedy equals tragedy plus time” needs to be modified. A research team led by University of Colorado psychologist A. Peter McGraw concludes that, at some specific point in the days and weeks after a horrible event, there is a “sweet spot” when we’re particularly likely to find humor in the darkness.

“Transforming tragedy into comedy requires time—not too little, yet not too much,” the researchers write in the journal Social Psychological and Personality Science.

"Humor arises when something that threatens a person’s well-being, identity, or normative belief structure simultaneously seems OK, safe, or acceptable."

Their online study featured 1,064 people (mean age 31) recruited from Amazon’s Mechanical Turk. Surveys of approximately 100 individuals were taken at 10 different points in time: one day before Sandy hit the Northeastern U.S.; October 30, the day it made landfall; and periodically over the next three months (November 2, 7, 14, 21, and 28, December 5, January 2, and February 6).

All the participants were asked to respond to three Sandy-related tweets, including the following: “Jus blew da roof off a Olive Garden. Free Breadsticks 4 Everyone!” Among other things, they were asked to rate on a one-to-seven scale how funny, offensive, and boring they found it.

Not surprisingly, in the initial groups, people found it less funny as word spread of the storm's devastation. “Humor was at a low point on November 14, 2012,” the researchers report.

However, “As time passed, it became OK to find humor in the tragedy, increasing the humor perceived in the tweets to a peak point on Dec. 5.”

After that, “Humorous responses to the tweets dropped again to another low point 99 days after the storm hit,” the researchers note. By that point, the quips came across as just as unfunny as they did the week of the tragedy.

McGraw and his colleagues argue these results provide evidence supporting the “benign violation theory” of humor. It states that “humor arises when something that threatens a person’s well-being, identity, or normative belief structure simultaneously seems OK, safe, or acceptable.”

Or to put it more simply: “Humor requires threat, but not too much, or too little.”

So if you fear an approaching hurricane could actually hurt you, your interests, or someone you love, there’s nothing funny about it. If the threat has safely passed, its potential to generate humor rapidly retreats.

But the moment when you feel you have dodged a bullet: That’s ripe for laughs.

Humor, McGraw and his colleagues write, is a great example of “the human capacity for taking a source of pain and transforming it into a source of pleasure.” (In that way, it’s like the blues.) This ability, they add, “is a critical feature of the psychological immune system.”

But their research shows this immune response only kicks in when we sense we’re safe, at least for the moment. It does not seem to work for long-running, slow-moving disasters.

Speaking of which, did you hear the one about the lousy economy and the Congress that refused to extend unemployment benefits?

Wait—too soon?