Skip to content

Commit

Permalink
util_update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lungsangg committed Jan 17, 2025
1 parent 2f9cc93 commit 0f377c2
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions static/js/sefaria/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import humanizeDuration from 'humanize-duration';
import sanitizeHtml from 'sanitize-html';
import Sefaria from './sefaria';
import {HDate} from '@hebcal/core';
import '../../css/s2.css';

var INBROWSER = (typeof document !== 'undefined');

Expand Down Expand Up @@ -99,7 +98,7 @@ class Util {
const yearString = getTibetanNumberAsString(year);
const monthString = getTibetanNumberAsString(month);
const dateString = getTibetanNumberAsString(date);
return `<span className="bo-date"> ཕྱི་ལོ <sub>${yearString}</sub> ཟླ་ <sub>${monthString}</sub> ཚེས་ <sub>${dateString}</sub></span>`
return `<span>སྤྱི་ལོ <sub>${yearString}</sub> ཟླ་ <sub>${monthString}</sub> ཚེས་ <sub>${dateString}</sub></span>`
}

function getTibetanNumberAsString(num) {
Expand Down Expand Up @@ -1149,7 +1148,6 @@ Util.sefariaHumanizeDuration = humanizeDuration.humanizer({
units: ['y', 'mo', 'w', 'd', 'h', 'm', 's'],
largest: 1,
round: true,
spacer: '', // Remove default spacing
unitMeasures: {
y: 365 * secsInDay,
mo: 30 * secsInDay,
Expand All @@ -1161,33 +1159,27 @@ Util.sefariaHumanizeDuration = humanizeDuration.humanizer({
},
languages: {
shortEn: {
y: (c) => `${c}y`,
mo: (c) => `${c}mo`,
w: (c) => `${c}w`,
d: (c) => `${c}d`,
h: (c) => `${c}h`,
m: (c) => `${c}m`,
s: (c) => `${c}s`,
ms: (c) => `${c}ms`,
y: () => "y",
mo: () => "mo",
w: () => "w",
d: () => "d",
h: () => "h",
m: () => "m",
s: () => "s",
ms: () => "ms",
},
shortBo: {
y: (c) => `ལོ་${Util.convertToTibetanNumeral(c)}སྔོན།`,
mo: (c) => `ཟླ་${Util.convertToTibetanNumeral(c)}སྔོན།`,
w: (c) => `བདུན་ཕྲག་${Util.convertToTibetanNumeral(c)}སྔོན།`,
d: (c) => `ཉིན་${Util.convertToTibetanNumeral(c)}སྔོན།`,
h: (c) => `ཆུ་ཚོད་${Util.convertToTibetanNumeral(c)}སྔོན།`,
m: (c) => `སྐར་མ་${Util.convertToTibetanNumeral(c)}སྔོན།`,
s: (c) => `སྐར་ཆ་${Util.convertToTibetanNumeral(c)}སྔོན།`,
ms: () => "སྟོང་ཆ་གཅིག་སྔོན།",
y: () => "ཕྱི་ལོ",
mo: () => "ཟླ་",
w: () => "བདུན་ཕྲག་",
d: () => "ཚེས་",
h: () => "ཆུ་ཚོད་",
m: () => "སྐར་མ་",
s: () => "སྐར་ཆ་",
ms: () => "སྟོང་ཆ་གཅིག་",
},
},
});

// Add this utility function to convert Arabic numerals to Tibetan numerals
Util.convertToTibetanNumeral = function(number) {
const tibetanNumerals = ['༠', '༡', '༢', '༣', '༤', '༥', '༦', '༧', '༨', '༩'];
return number.toString().split('').map(digit => tibetanNumerals[parseInt(digit)]).join('');
};


export default Util;
export default Util;

0 comments on commit 0f377c2

Please sign in to comment.