K
K
Konstantin Tsvetkov2022-01-07 15:26:55
Calendar
Konstantin Tsvetkov, 2022-01-07 15:26:55

How to calculate the day of the week according to the unearthly calendar?

Zhenechka Kartushin deleted the question:

The planet Tempos is 1000 years old today. On the calendar 10.01.1001, Wednesday. The settlement was founded on Sunday.
There are slight differences in the Tempos calendar from the earthly one. 12 months for 28 days. And in February of a leap year, 29. A year will be considered a leap year if it is a multiple of 5, but of those that are a multiple of 100, only those that are a multiple of 500 will be leap years. For example, 200, 300, 400 are non-leap years, 500 are leap years.
Determine what day of the week is Tempos for any given date.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2022-01-07
@tsklab

-- 10.01.1001
DECLARE @Y INT = 1001, @M INT = 1, @D INT = 10
DECLARE @DN INT
-- 12 месяцев по 28 дней
SET @DN = 28 * 12 * @Y
-- в феврале високосного года 29, кратен 5
IF ((@Y % 5) = 0) 
  SET @DN = @DN + (@Y / 5)
-- кратны 100 високосными будут только те
IF ((@Y % 100) = 0) 
  SET @DN = @DN - (@Y / 100)
-- кратны 500
IF ((@Y % 500) = 0) 
  SET @DN = @DN + (@Y / 500)
-- месяц, день
SET @DN = @DN + ((@M - 1) * 28)
SET @DN = @DN + @D
-- текущий год високосный и дата больше 28.02?
IF ((@Y % 5) = 0) 
      AND (((@Y % 100) <> 0) OR ((@Y % 500) = 0))
      AND (@M >= 3) 
  SET @DN = @DN + 1

SELECT CONCAT_WS( '.', @D, @M, @Y), DATENAME( weekday, (@DN % 7) - 1 )

10.1.1001 среда

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question