📸 Heads up! This is a highly visual post! Expect plenty of screenshots and photos from my gallery to make the walkthrough more fun and easy to follow.
Since the first image in a blog post often becomes its thumbnail, I wanted something deliberate—not a random, awkwardly cropped photo. So, I made this 👇 one in Canva.
![]() |
The Spark ✨
I started collecting watches in 2021. I started off this hobby by collecting HMT watches, and now my collection includes HMT, a bunch of G-Shocks and Casio watches, a few Timex models, and watches from microbrands like Pagani Design. I like collecting watches with unique designs. Here are the pics of some unique watches from my collection.
![]() |
Picto Stick and Ball watch |
![]() |
Kalaksh Time-Turner |
![]() |
Titan Geometrix |
![]() |
Casio G-Shock GA-V01 |
![]() |
Fastrack x Coca-Cola |
The latest one that I added to my collection was the SKMEI 2312.
SKMEI is a Chinese watch brand known for offering a wide variety of affordable timepieces. They make watches that look very similar to popular brands (like Casio) but are affordable and considered homage. SKMEI 2312 is an homage to the QlockTwo W Watch, which is a unique watch that doesn't use hands or digital numbers to tell the time. Then, how does it show the time, you may wonder? It tells time in words like "IT IS FIVE PAST ONE."
Here 👇 are some pics of the SKMEI 2312.
![]() |
Wrist Shot |
My inspiration for this little project, which, btw, you're reading as a blog post now, came from the SKMEI 2312, which got me thinking, if a watch can tell time in words, why not make a COBOL program do the same?
First time with OpenCOBOL IDE
I usually prefer JDoodle's Online COBOL compiler to write COBOL programs on the go. But, for this project, I thought of trying the OpenCOBOL IDE on my personal laptop. I really loved the coding experience. It's a lightweight IDE with some useful features like a syntax highlighter, vertical grid lines indicating Area A and Area B, a navigation window showing the structure of the program with collapsible buttons, an offset calculator, etc. It would've been fantastic if there was an in-built debugger.
The Logic 🧠
The initial idea was to use the intrinsic function, FUNCTION CURRENT-DATE in COBOL, to get the hour and minute. Process the hour and minute separately to determine how to express them in words. The code heavily relies on several EVALs, which do the magic of expressing the time in words.
Click on this -> link to execute the code on JDoodle.
Please note that this code displays the time in words the moment you hit the Execute button, referring to the hour and minute during that moment. It doesn't act like an actual clock (which updates the time every minute).
Testing Like a Modern Mainframer
After coding the logic, I decided to test it for every possible minute in the day. I asked ChatGPT to generate an input file of LRECL 4, with each line having the time in HHMM format starting from 0000 to 2359. I also shared the COBOL logic I created on OpenCobolIDE and asked the AI assistant to modify the code to accommodate logic for reading the input file and writing to the output file. The intent was to write a record to the output file with the time expressed in words for each record read from the input file. For example, "IT IS TWELVE IN THE MORNING" for 0000.
![]() |
Screenshot of the input file that ChatGPT generated. |
The logic that I wrote in COBOL expresses the time in words for each minute of the day. The program handles the AM/PM by representing the time period at the end of the sentence, like this:
- Hours < 12 → “IN THE MORNING”
- Hour = 12 → “IN THE NOON”
- Hours > 12 & < 17 → “IN THE AFTERNOON”
- Hours ≥ 17 & < 21 → “IN THE EVENING”
- Hours ≥ 21 → “IN THE NIGHT”
The SKMEI 2312 watch (or the QlockTwo W watch for that matter) doesn't express the time in words for each minute. The watch displays the time in five-minute intervals. For example, it will show the time as "IT IS FIVE PAST TWO.", then "IT IS TEN PAST TWO." To indicate the exact minutes, there are 4 dots at each corner of the square grid of letters. The number of dots lit up at a specific time equals that many minutes plus the minute part of the time expressed in words. For example, if the time is displayed as "IT IS FIVE PAST TWO" with two dots lit up, the exact time is "IT IS SEVEN PAST TWO."
![]() |
The watch displays "IT IS TO TWO" with a dot lit up on the top left corner of the watch. This means, "IT IS ONE TO TWO" i.e., 01:59. |
The Blog widget idea 💡
I'm running this blog on Blogger by Google. It allows me to edit the layout of the site. I can add/edit gadgets to my blog. For example, the IBM Champions badge that you see on the right side (if you're reading this post using the web version of this blog) is an HTML/Javascript gadget. IBM provided this badge through Credly, and Credly provides me with the code to display the badge on a web page, blog, or anywhere else that accepts HTML.
Since I had already added a number of gadgets to my blog, I thought, "Why not add this Time In words gadget as well?"
Once the logic was stable, I leaned on ChatGPT (again) with the following prompt:
How can I show this time-in-words as a live widget on my blog?
Out of many ideas that it provided, I chose the one that suggested,
- hosting OUTPUT.txt file on GitHub Pages
- Use Javascript to read the current time (in HHMM format)
- Use the HHMM value to look up the matching line in the file hosted on GitHub Pages
- Display the time in words, updating every minute
First time with GitHub Pages
I had never used GitHub Pages before, but it turned out to be perfect. In a nutshell, GitHub Pages is like a website for your GitHub repository.
I created this GitHub repo and added the COBOL program and input/output files. I set up the GitHub Pages on my repo to host the OUTPUT.txt file so that it's available in public and can be fetched by the blog widget.
GitHub Pages on the repo is disabled by default, and you can enable it by configuring a publishing source for your site. Publishing source, in my case, is the main branch root folder of the repo. All the files that I added/will be adding to the repo will be immediately published on the site.
If you know the exact filename in the repository, you can view its contents directly by appending the filename to the site’s URL.
For example, starting from the main site URL, https://jvsrinivasan.github.io/time-in-words/ adding
For example, starting from the main site URL, https://jvsrinivasan.github.io/time-in-words/ adding
OUTPUT.txt
at the end (https://jvsrinivasan.github.io/time-in-words/OUTPUT.txt) will open that file’s contents in your browser.It's time to show time 🕐
After hosting the OUTPUT.txt file using GitHub Pages, I asked ChatGPT to help me with the HTML/JavaScript code for the blog's widget.
After some interaction, I was able to obtain a working code that,
- Runs every minute (
setInterval
) - Gets the current time (
new Date()
) - Formats it to
HHMM
- Looks up the matching line from
OUTPUT.txt
- Displays the time in words in a black background with green monospaced text to give the blog widget that nostalgic Mainframe terminal look 😎🟩⬛
Here is the code:
<div id="time-in-words-widget" style="background-color:black; color:#00ff00; font-family:monospace; font-size:20px; padding:10px; border-radius:5px; text-align:center;">
Loading time in words...
</div>
<script>
async function showTimeInWords() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const hhmm = hours + minutes;
try {
const response = await fetch("https://your-username.github.io/time-in-words/OUTPUT.txt?cache=" + Date.now());
const text = await response.text();
const lines = text.split('\n');
const match = lines.find(line => line.startsWith(hhmm));
const output = match ? match.substring(5).trim() : "Time not found";
document.getElementById("time-in-words-widget").innerText = output;
} catch (error) {
document.getElementById("time-in-words-widget").innerText = "Error loading time.";
}
}
showTimeInWords();
// Align with start of next minute
const delay = (60 - new Date().getSeconds()) * 1000;
setTimeout(() => {
showTimeInWords();
setInterval(showTimeInWords, 60000);
}, delay);
</script>
Here is a pic of the blog with the gadget in action:
Closing thoughts
I could’ve done this in Python/Javascript. But I blog about COBOL—not because it’s trendy, but because it powers the systems most people don’t realize they depend on. This was my way of showing that COBOL can still surprise you. And sometimes, inspiration (for a little project) comes from something as simple as your watch.
As a side note, a big thank you to IBM for sending me the IBM Champion merch package. This year marks my 4th consecutive year as an IBM Champion. Here is a pic of everything that IBM sent me in the package:
No comments:
Post a Comment