Calculate Swatch Internet Time Codes

PHP

12 bytes:
<?php echo date('B'); ?>
48 bytes:
<?php echo sprintf("%03d",((time()+3600)%86400)/86.4|0); ?>

C, 56 bytes

main(){printf("%03d",(int)((time(0)+3600)%86400/86.4));}
Explanation:
  • %03d - tells printf to zero-pad up to 3 digits.
  • time(NULL)+3600 - gets amount of seconds (UTC) elapsed since epoch and adds an hour to it (UTC+1).
  • %86400 - divides epoch by the amount of seconds in a 24hr day and gets the remainder (representing seconds elapsed, so far, "today").
  • /86.4 - divide remaining seconds by 86.4 to get the ".beat" count since midnight (UTC+1).

Compile (MSVC):

C:> cl swatch.c

Compile (GCC):

$ gcc swatch.c

Java 143 bytes

import java.time.*;
interface A {
  static void main(String[] a) {
    System.out.format("%03.0f", LocalTime.now(ZoneId.of("UT+1")).toSecondOfDay() / 86.4);
  }
}
Javascript
    d=new Date();t=;console.log(Math.floor((360*d.getHours()+60*d.getMinutes()+d.getSeconds())/86.4));
  

0 Response to "Calculate Swatch Internet Time Codes"

Post a comment

Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.

If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel

loading...