From b20bf5c8420ad43cd5a0922736c98e4764fc983b Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 27 Aug 2024 17:13:26 +0200 Subject: [PATCH] Document use of meridian --- tutorials/Bangle.js Locale.md | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tutorials/Bangle.js Locale.md b/tutorials/Bangle.js Locale.md index 08476227..a3a9dba6 100644 --- a/tutorials/Bangle.js Locale.md +++ b/tutorials/Bangle.js Locale.md @@ -25,11 +25,19 @@ How do you use it? Simply call `require("locale")` in your code and use the provided object. -For instance, if you want to write a date in a locale-friendly way, just use: +For instance, if you want to show the clock in a locale-friendly way, just use: ```JS -var myDate = new Date(); -var dateString = require("locale").date(myDate); +let myDate = new Date(); +let clockString = require("locale").time(myDate) + " " + require("locale").meridian(myDate); +g.drawString(clockString); +``` + +And for a locale-friendly date: + +```JS +let myDate = new Date(); +let dateString = require("locale").date(myDate); g.drawString(dateString); ``` @@ -94,15 +102,27 @@ correctly in the console. They may need to be rendered with // Date to time string (long) >require("locale").time(new Date()) -="15:49:39" +="03:49:39" // If user chose 12-hour clock +="15:49:39" // If user chose 24-hour clock // Date to time string (short) >require("locale").time(new Date(), 1) -="15:49" +="03:49" // If user chose 12-hour clock +="15:49" // If user chose 24-hour clock // Date to meridian (text describing morning/evening) >require("locale").meridian(new Date()) -="" // or "pm" for en_GB +="PM" // If user chose 12-hour clock +="" // If user chose 24-hour clock + +// Date to meridian (forced) +>require("locale").meridian(new Date(), true) +="PM" // No matter which hour format is used + +// Check which hour format the watch uses +>require("locale").is12Hours() +=true // If user chose 12-hour clock +=false // If user chose 24-hour clock ``` `date_utils` module