• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru: Make It Easy On Someone Else

    August 20, 2018 Ted Holt

    “Make it easy on yourself,” warbled Dionne Warwick when I was just a pup. That may be good advice when severing a romantic relationship, but not when programming computers. Instead of making it easy on ourselves, we who develop and support applications need to make it easy on the people we serve.

    Recently I worked on a project in which users had to enter time values into various Web pages. The original specifications stated that users would enter time values in a format we commonly use in the United States: two-digit hour, a colon, two-digit minute, a space, and either AM or PM. For example:

    10:30 PM
    

    Something seemed wrong about this idea. It would be difficult for me to think of a more unwieldy data-entry format. There are too many opportunities for the user to key the value improperly. What if the user only keys one digit for the hour? What if the user omits the space after the minute?

    This story contains code, which you can download here.

    HTML supports a type=”time” attribute for the <input> tag, but it was not an option, I assume due to how that attribute behaves in certain browsers. Given the constraints, how could I make time entry as easy as possible for the people who would be using those Web pages?

    I decided to write a routine that would allow the user:

    • to key time in either 12-hour or 24-hour format
    • to key hours and minutes only, or to key hours, minutes, and seconds
    • to key a separator character or not
    • to use a colon or period as the separator character
    • to key a leading zero for one-digit hours or not
    • to leave spaces or not
    • to key AM or PM, or even more simply, A or P, in either upper- or lowercase

    The user could key 8:30 AM and 2:30 PM in any of the following formats and more:

    830 1430
    8:30 14:30
    8.30 14.30
    830a 230p
    0830am 0230pm
    8:30am 2:30pm
    8:30 A 2:30 P
    8.30 AM 2.30 PM

    Did it work? You’d better believe it! They liked it so much they changed the Web pages that they had already built to call the new routine.

    I wrote the routine in RPG, then wrote a JavaScript version from the RPG version. Since I wrote the RPG version on my own time, you can have it. (See the downloadable code.)

    I put the RPG source code into a single member, which you can compile as a program or module. If you compile it as a program, it will produce a report that shows each step it takes to interpret a time value. This is how I developed the routine. If you compile it into a module, you can create a service program to which other applications can bind. For completeness, I also added a subprocedure that you can call through an SQL interface.

    By the way, some years ago, IT Jungle published a routine for entering date values in various formats. That article seems to have become a casualty of our move to WordPress. I will try to put my hands on it and republish it. After all, I may need that routine myself someday.

    Think of your own shop. Whether you’re delivering modern browser-based applications or still using green screens, what’s causing the users consternation? What’s eating up their time? What can you do to make it easy for someone else?

    RELATED STORY

    HTML <input type=”time”> (w3schools)

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    Tags: Tags: FHG, Four Hundred Guru, IBM i, SQL

    Sponsored by
    Computer Keyes

    Create Full Color Overlays, Interactive PDFs

    KeyesOverlay rapidly converts standard *SCS printer files into eye-catching PDF documents. Create graphical overlays in full color (or black and white if preferred) then easily map your spooled file text with different fonts, sizes and colors!

    KeyesOverlay can also create Interactive Forms for your customers to fill out and email or submit back to you.

    www.computerkeyes.com

    Share this:

    • Share on Reddit (Opens in new window) Reddit
    • Share on Facebook (Opens in new window) Facebook
    • Share on LinkedIn (Opens in new window) LinkedIn
    • Share on X (Opens in new window) X
    • Email a link to a friend (Opens in new window) Email

    GDPR Compliance On IBM i A Work In Progress, Survey Finds In Support Of IBM i Technical Competence

    3 thoughts on “Guru: Make It Easy On Someone Else”

    • Russ Khoury says:
      August 21, 2018 at 5:32 am

      Hi Ted, your article reminds me of times I would be writing or modifying some code (even my own and certainly back in my S/36 days) and I’d be testing it. After entering data a few times I’d realize I wouldn’t want to do this every day and would try to come up with a better/easier/faster way to do the data entry. I don’t often see developers looking at their code in the way you describe. They’re satisfied to just get it working. Sigh. All the best.

      Reply
    • Lloyd Bailey says:
      August 21, 2018 at 4:48 pm

      12:00 AM returns back noon and not the expected midnight. Modified the IF, where your checking if time needs to increase by 12, to correct this.

      Reply
    • Ted Holt says:
      December 5, 2019 at 7:13 am

      Thanks for letting me know, Lloyd. I fixed that code.

      Reply

    Leave a ReplyCancel reply

TFH Volume: 28 Issue: 54

This Issue Sponsored By

  • ProData Computer Services
  • T.L. Ashford
  • RPG & DB2 Summit
  • ML Software
  • WorksRight Software

Table of Contents

  • Drilling Down Into The Power E980
  • In Support Of IBM i Technical Competence
  • Guru: Make It Easy On Someone Else
  • GDPR Compliance On IBM i A Work In Progress, Survey Finds
  • Address Those Fears And Move Your IBM i Workloads To The Cloud

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Power Systems Turns In Another Great Quarter
  • Big Blue Is Right On Schedule With Fall 2026 IBM i Tech Refreshes
  • Guru: Environment Variables – Global Variables Wearing Hiking Boots
  • A New IBM i Entity Takes Shape: Power By Fortra
  • IBM i PTF Guide, Volume 28, Number 38
  • Critical PHP2Shell Security Vulns Evoke ‘Black October’
  • Why Fortra Partnered with FalconStor to Launch Continuity Care: A Validated Recovery Service for IBM i
  • Guru: Analyzing User Session Statistics, Part 2
  • Fresche Launches OpsIQ, a Free AI-Based Operation Assistant for IBM i
  • IBM i PTF Guide, Volume 28, Number 37

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle