# Calculate the IST : Indian Standard Time

Given two integer H and R where H is the time in hours at a place X and R is the distance in degrees from place X to India, the task is to find the current time in IST.

UTC (Coordinated Universal Time) is a 24-hour time standard that is used to synchronize world clocks.

Examples:

Input: H = 24, R = 82.50
Output: IST = 5:30
IST = (24/360)* 82.50
= 5.5
= 0.5*60 (i.e 60 minute = 360 degree rotation and 1 minute = 6 degree so, 0.5 hour * 60 = 30)
IST = 5:30

Input: H = 20, R = 150
Output: IST = 8:20

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach:

• It is known that 1 hour = 60 minute = 360 degree rotation.
• 1 degree rotation = (1 / 360) hour.
• 2 degree rotation = (1 / 360) * 2 hour.
• So, Generalised formula will be:
```IST = UTC + (H / 360) * R (UTC = 0 for IST)
IST = ( H / 360 ) * R
```

The answer will be converted in 0:00 form so int part (hour) and float part in IST are separated and the float part is multiplied by 60 to convert it into minutes.

Below is the implementation of the above approach:

## C++

 `// C++ implementation of the approach ` `#include ` `#include ` `using` `namespace` `std; ` ` `  `// Function to calculate Indian Standard Time ` `void` `cal_IST(``int` `h, ``float` `r) ` `{ ` `    ``float` `IST = (h * r * 1.0) / 360; ` ` `  `    ``// Separate integer part ` `    ``int` `int_IST = (``int``)IST; ` ` `  `    ``// Separate float part and return ceil value ` `    ``int` `float_IST = ``ceil``((IST - int_IST) * 60); ` ` `  `    ``cout << int_IST << ``":"` `<< float_IST; ` `} ` ` `  `// Driver code ` `int` `main() ` `{ ` ` `  `    ``// Number of hours (1 - 24) ` `    ``int` `h = 20; ` ` `  `    ``// Rotations in degrees ` `    ``float` `r = 150; ` ` `  `    ``cal_IST(h, r); ` ` `  `    ``return` `0; ` `} `

## Java

 `// Java implementation of the approach  ` `import` `java.math.*; ` ` `  `class` `GFG ` `{ ` `    ``// Function to calculate Indian Standard Time  ` `    ``public` `static` `void` `cal_IST(``int` `h, ``double` `r)  ` `    ``{  ` `        ``double` `IST = (h * r * ``1.0``) / ``360``;  ` ` `  `        ``// Separate integer part  ` `        ``int` `int_IST = (``int``)IST;  ` ` `  `        ``// Separate float part and return ceil value  ` `        ``int` `float_IST = (``int``)Math.ceil((``int``)((IST - int_IST) * ``60``));  ` ` `  `        ``System.out.println(int_IST + ``":"` `+ float_IST);  ` `    ``}  ` ` `  `    ``// Driver code  ` `    ``public` `static` `void` `main(String[] args)  ` `    ``{  ` `     `  `        ``// Number of hours (1 - 24)  ` `        ``int` `h = ``20``;  ` `     `  `        ``// Rotations in degrees  ` `        ``double` `r = ``150``;  ` `     `  `        ``cal_IST(h, r);  ` `    ``} ` `}  ` ` `  `// This code is contributed by Naman_Garg `

## Python3

 `# Python3 implementation of the approach  ` `from` `math ``import` `ceil ` ` `  `# Function to calculate Indian Standard Time  ` `def` `cal_IST(h, r) :  ` ` `  `    ``IST ``=` `round``((h ``*` `r ``*` `1.0``) ``/` `360``, ``3``);  ` ` `  `    ``# Separate integer part  ` `    ``int_IST ``=` `int``(IST);  ` ` `  `    ``# Separate float part and return ceil value  ` `    ``float_IST ``=` `ceil((IST ``-` `int_IST) ``*` `60``);  ` ` `  `    ``print``(int_IST, ``":"``, float_IST);  ` ` `  `# Driver code  ` `if` `__name__ ``=``=` `"__main__"` `:  ` ` `  `    ``# Number of hours (1 - 24)  ` `    ``h ``=` `20``;  ` ` `  `    ``# Rotations in degrees  ` `    ``r ``=` `150``;  ` ` `  `    ``cal_IST(h, r);  ` ` `  `# This code is contributed by AnkitRai01 `

Output:

```8:20
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : AnkitRai01, Naman_Garg

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.