|
1 | 1 | const boldFont = require("./fonts/Roboto-Black-normal"); |
2 | | -const regularFont = require("./fonts/Roboto-Regular-normal") |
3 | | -const { titleFontSize, textFontSize, xStart, yStart, yRange} = require("./constants"); |
4 | | -const moment = require('moment'); |
| 2 | +const regularFont = require("./fonts/Roboto-Regular-normal"); |
| 3 | +const { |
| 4 | + titleFontSize, |
| 5 | + textFontSize, |
| 6 | + xStart, |
| 7 | + yStart, |
| 8 | + yRange, |
| 9 | +} = require("./constants"); |
| 10 | +const moment = require("moment"); |
5 | 11 | const { default: slugify } = require("slugify"); |
6 | | -require('moment/locale/fr.js'); |
| 12 | +require("moment/locale/fr.js"); |
7 | 13 |
|
8 | 14 | const getDateAndTime = () => { |
9 | | - moment.locale('tr') |
10 | | - return moment().format('L') + ' - ' + moment().format('LT') |
11 | | -} |
| 15 | + const date = new Date().toLocaleString("tr-TR", { |
| 16 | + timeZone: "Europe/Moscow", |
| 17 | + }); |
| 18 | + return date.toString(); |
| 19 | +}; |
12 | 20 |
|
13 | 21 | const registerFont = (doc) => { |
14 | | - doc.addFileToVFS("./fonts/Roboto-Black.ttf", boldFont.font); |
15 | | - doc.addFileToVFS("./fonts/Roboto-Regular.ttf", regularFont.font); |
16 | | - doc.addFont("./fonts/Roboto-Black.ttf", "Roboto-Black", "normal"); |
17 | | - doc.addFont("./fonts/Roboto-Regular.ttf", "Roboto-Regular", "normal"); |
18 | | - doc.setFont('Roboto-Regular', 'normal'); |
19 | | - |
20 | | -} |
| 22 | + doc.addFileToVFS("./fonts/Roboto-Black.ttf", boldFont.font); |
| 23 | + doc.addFileToVFS("./fonts/Roboto-Regular.ttf", regularFont.font); |
| 24 | + doc.addFont("./fonts/Roboto-Black.ttf", "Roboto-Black", "normal"); |
| 25 | + doc.addFont("./fonts/Roboto-Regular.ttf", "Roboto-Regular", "normal"); |
| 26 | + doc.setFont("Roboto-Regular", "normal"); |
| 27 | +}; |
21 | 28 |
|
22 | 29 | const setFont = (doc, type) => { |
23 | | - if (type == "regular") { |
24 | | - doc.setFont('Roboto-Regular', 'normal'); |
25 | | - } else { |
26 | | - doc.setFont('Roboto-Black', 'normal'); |
27 | | - } |
28 | | -} |
| 30 | + if (type == "regular") { |
| 31 | + doc.setFont("Roboto-Regular", "normal"); |
| 32 | + } else { |
| 33 | + doc.setFont("Roboto-Black", "normal"); |
| 34 | + } |
| 35 | +}; |
29 | 36 |
|
30 | 37 | const slug = (text) => { |
31 | | - return slugify(text, { |
32 | | - trim: true // trim leading and trailing replacement chars, defaults to `true` |
33 | | - }) |
34 | | -} |
35 | | - |
| 38 | + return slugify(text, { |
| 39 | + trim: true, // trim leading and trailing replacement chars, defaults to `true` |
| 40 | + }); |
| 41 | +}; |
36 | 42 |
|
37 | 43 | module.exports = { |
38 | | - setFont, |
39 | | - registerFont, |
40 | | - getDateAndTime, |
41 | | - slug, |
42 | | - |
43 | | -} |
| 44 | + setFont, |
| 45 | + registerFont, |
| 46 | + getDateAndTime, |
| 47 | + slug, |
| 48 | +}; |
0 commit comments