Web based family history software

Question Date format settings - addon or change coode for config.ini.php

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago #1 by webtreesFUN
Also looking option to change date format globally and set this format i db. It should be simple as more..
Code:
<?php class ChangeDateFormatPlugin extends WT_Module {     static function getName() {         return 'Change Date Format';     }     static function getDescription() {         return 'Changes date format in panel to custom format';     }     static function isEditable() {         return false;     }     static function getOptions() {         return array(             'date_format' => array(                 'type' => 'text',                 'title' => 'Date Format',                 'default' => 'Y-m-d',                 'description' => 'Enter date format (e.g., Y-m-d)'             )         );     }     static function init() {         $date_format = self::getOption('date_format', 'Y-m-d');         add_filter('WT_Date', array(__CLASS__, 'changeDateFormat'), 10, 2);     }     static function changeDateFormat($date, $format) {         return date($format, strtotime($date));     } } WT_registerModule('ChangeDateFormatPlugin');

Please Log in or Create an account to join the conversation.

More
10 months 1 week ago #2 by hermann
Can you explain, why there is a need to change the date format? Is it how dates should be shown or a more flexible method to enter dates? The date format depends on the language of the user. Why should this be changed?

Hermann
Designer of the custom module "Extended Family"

webtrees 2.1.21 (all custom modules installed, PHP 8.3.12, MariaDB 10.6) @ ahnen.hartenthaler.eu

Please Log in or Create an account to join the conversation.

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago - 10 months 1 week ago #3 by webtreesFUN
Sure, coz in some countries the date culture is other and when working with data to put is more comfy to put ready prepared data like:
YYYY-MM-DD than D, Month , YYYY etc.
Eg. format how we see in diagram, reports (can be used form more analysis, operate with data), exports and other addons.

Its more how user seeing fina view, and input fields for GUI components.
Eg. when you change language to other from EN in pickup tool and input is still English format as 1 JAN 2024 not language. I think coz it's not universal setting but default.
Last edit: 10 months 1 week ago by webtreesFUN.

Please Log in or Create an account to join the conversation.

  • JustCarmen
  • Away
  • Elite Member
  • Elite Member
More
10 months 1 week ago #4 by JustCarmen
webtrees already takes into account different date formats.

You can test it yourself. Set the language on American English and the American date format is used, eg August 7, 1894.
Set the language on British English and the European date format is used, eg 7 August 1894


Carmen
Designer of the JustLight theme (comes with a light and dark color palette), Fancy Imagebar, Fancy Research Links and Fancy Treeview for webtrees 2


Check my website at www.justcarmen.nl

Please Log in or Create an account to join the conversation.

  • fisharebest
  • Away
  • Administrator
  • Administrator
More
10 months 1 week ago #5 by fisharebest
The date format is set by each language, by creating a translation of the string: '%j %F %Y'

There is an example module that shows how to define/override translations. Just set it to the format you want for each language.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago - 10 months 1 week ago #6 by webtreesFUN
I think is not clear.. watch:

 
 

By this can type as friendly ready date form other sources as: 1958-05-01 etc.. must be 01 may 1958
Last edit: 10 months 1 week ago by webtreesFUN.

Please Log in or Create an account to join the conversation.

  • fisharebest
  • Away
  • Administrator
  • Administrator
More
10 months 1 week ago #7 by fisharebest
> must be 01 may 1958

No. You can use many different formats to enter data.

Click the help icon at the end of the input field to see them.

So, you can type 01/05/1958 or 1958-05-01 or many other formats.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • norwegian_sardines
  • Offline
  • Platinum Member
  • Platinum Member
More
10 months 1 week ago #8 by norwegian_sardines
Did you actually try to enter the date 1958-05-01?

Ken

Please Log in or Create an account to join the conversation.

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago #9 by webtreesFUN
I think I getting the philosophy. Soo pickup tool limiting format view as standard where we can't set own format but we can put universal?

Yes I put, it working. Before I not recognized that JS replacing format in fact.

But still referring to the view in many places.

Please Log in or Create an account to join the conversation.

  • norwegian_sardines
  • Offline
  • Platinum Member
  • Platinum Member
More
10 months 1 week ago #10 by norwegian_sardines
GEDCOM has a standard way it stores date data (as should all databases) into its file, it is DD MMM CCYY.  Dates are all human readable (not some number based on the seconds away from an arbitrary starting point) values using English based month names.  This is the way it is!



 

Ken

Please Log in or Create an account to join the conversation.

  • fisharebest
  • Away
  • Administrator
  • Administrator
More
10 months 1 week ago #11 by fisharebest
The date format "01 MAY 1858" is defined by the GEDCOM standard.

Whatever the user types, webtrees *must* convert it to this format.

For experienced users, it is always quicker/easier to type GEDCOM format.

Dates can have very complicated formats (different calendars, ranges, etc.), and a point/click interface for this would be also need to be very complicated.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago #12 by webtreesFUN
I understanding - database and standard. Ok.
But.. still about views for users, eg. format for export in pdf, etc. They can have own format and it's fine.
Event standard is DD m Y then view with ISO8601 Notations as YYYY-MM-DD can be more operatible.

Please Log in or Create an account to join the conversation.

  • fisharebest
  • Away
  • Administrator
  • Administrator
More
10 months 1 week ago #13 by fisharebest
> Event standard is DD m Y then view with ISO8601 Notations as YYYY-MM-DD can be more operatible.

The standard is not simply "DD MMM YYYY".

There are different calendars, date ranges, approximate dates, etc.

14 AUG 55 B.C.
@#DHEBREW@ 14 TVT 5432

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • webtreesFUN
  • Topic Author
  • Offline
  • New Member
  • New Member
More
10 months 1 week ago #14 by webtreesFUN
Yes I saw:

2 DATE 19 DEC 2023
3 TIME 19:34:52

As standard in gedcom, but finally in view user can what want.

Please Log in or Create an account to join the conversation.

  • norwegian_sardines
  • Offline
  • Platinum Member
  • Platinum Member
More
10 months 1 week ago #15 by norwegian_sardines
If the user has change the display language to one of the languages listed in the “language” dropdown, the entered month should change to their language.  For example in Norwegian June becomes juni and October becomes oktober.  This should be true for all languages that have a translation set up!

Ken

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum