If your days are numbered, it isn’t necessarily bad news, as everybody only has a certain number of days anyway, but this idiom or trope is often used in conjunction with pending doom of one kind or another. This might mean that death is imminent or it might simply mean a current situation is about to change or come to an end. For instance if a boss tells an employee "your days are numbered," it’s a pretty good indication that a pink slip is forthcoming. On the other hand, if a doctor says the same thing to a patient, this would be incredibly insensitive, yet the meaning would probably be clear.
The meaning of the idiom “days are numbered” is both literal and figurative. The phrase can be applied to an inanimate object as well. For example, consider the following sentence - “Based on that awful squeaking sound, I’d say my washing machine’s days are numbered.” In this example, it implies that the washing machine in question is likely to break down soon, bringing it’s functionality to an end. In examples such as this, saying that something’s days are numbered is often synonymous with something being “on its last legs,” another popular idiom indicating the end of something.
When not referring to something, but rather someone, "days are numbered" can indicate a variety of things. More than one US President has referred to another individual in power using this phrase in some form. It is also a phrase that is a common film and television trope. For example one character may threaten another with some form of the phrase and the meaning is obvious.
This phrase can be used in the first or the third person. While it is a phrase often used in reference to death, it has been used in book titles, television episode titles, movie scripts and political speeches in reference to a breadth of meanings from loss of power to apocalyptic times. In the literal sense though, since nothing lasts forever, the phrase is less of an idiom than many other common English phrases with meanings that are more ambiguous.
In normal conversation, if someone were to say your days were numbered, it could be perceived as ominous or threatening, or could be interpreted as a general observation depending on the context in which it was used. As a rule of thumb, it could be considered impolite or insensitive to observe or acknowledge someone in this way if they are actually terminally ill.