• 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:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

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

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • 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 Reply Cancel 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

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

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