/*
Name Project : Date And Time
Author : teknisi-dadakan.com @tdee_gits
Date : Februari 2023
*/
const NanoTimer = require('nanotimer');
const setTitle = require('console-title');
let title = "DATE AND TIME - TEKNISI-DADAKAN.COM"
setTitle(title)
let info;
let show_date;
let show_time;
info = (["\n",
"==========| DATE AND TIME |============",
" | - TEKNISI-DADAKAN.COM - |",
"======================================="
].join("\n"));
//===================================== TIMER DISPLAY FUNCTION
function DateIt(){
console.clear();
console.log(info);
let Namabulan = ["Januari","Februari","Maret","April",
"Mei","Juni","Juli","Agustus",
"September","Oktober","November","Desember"];
let NamaHari = ["Minggu","Senin","Selasa","Rabu",
"Kamis","Jumat","Sabtu"]
let dateIs = new Date().toLocaleString("en-US",
{ timeZone: "Asia/Jakarta" });
let date = new Date(dateIs);
let hari = date.getDay();
let tanggal = date.getDate();
let bulan = date.getMonth();
let tahun = date.getFullYear();
show_date ="Tanggal : " + tanggal+" "+Namabulan[bulan]+" "+tahun;
console.log("Hari : " + NamaHari[hari] + "\n" + show_date);
}
//============================================================
function Subtimered(){
Number.prototype.pad = function(n) {
for (var r = this.toString(); r.length < n; r = 0 + r);
return r;
};
}
//============================================================
function StartDate_and_Time(){
DateIt();
var SubTimeToGo = new NanoTimer();
SubTimeToGo.setInterval(TimeIt, '', 1000+'m');
}
//============================================================
function TimeIt() {
Subtimered();
let getDate = new Date().toLocaleString("en-US",
{ timeZone: "Asia/Jakarta" });
let date_now = new Date(getDate);
let jam = ("00" + date_now.getHours()).slice(-2);
let menit= ("00" + date_now.getMinutes()).slice(-2);
let detik= ("00" + date_now.getSeconds()).slice(-2);
let hhh_mmm_sss = jam + ":" + menit+ ":" + detik;
show_time = hhh_mmm_sss;
process.stdout.write("Jam : ["+show_time+"]\r");
if(show_time === "00:00:00"){DateIt();}
}
//======================================== TIMER DISPLAY START.
StartDate_and_Time();