Skip to content

GIOKTH/lao_date_format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lao DateTime Library

A Rust library for formatting and parsing dates in Lao language with Buddhist Era calendar support.

Features

  • Format dates in Lao language (ວັນ, ເດືອນ, ປີ)
  • Buddhist Era (BE) calendar conversion
  • Lao number formatting (໐໑໒໓໔໕໖໗໘໙)
  • Number to Lao text conversion (e.g., 123 -> "ໜຶ່ງຮ້ອຍຊາວສາມ")
  • Parse Lao date strings back to DateTime
  • Standard Gregorian date formatting (dd/mm/yyyy, dd-mm-yyyy, dd-MM-yyyy, dd/MM/yyyy)

Installation

Add this to your Cargo.toml:

[dependencies]
Lao_date_format = "0.2.2"

Usage

Creating a LaoDateTime instance

You can create a LaoDateTime instance using the new constructor:

use Lao_date_format::LaoDateTime;

let dt = LaoDateTime::new(2024, 3, 27, 14, 30, 0).expect("Invalid DateTime");

Number to Lao Text

Convert numbers to their full Lao spoken text representation:

use Lao_date_format::number_to_lao_text;

println!("{}", number_to_lao_text(123));
// Output: ໜຶ່ງຮ້ອຍຊາວສາມ

println!("{}", number_to_lao_text(1000000));
// Output: ໜຶ່ງລ້ານ

Formatting Dates and Times

Standard Date Formats (Gregorian)

use Lao_date_format::LaoDateTime;

let dt = LaoDateTime::new(2026, 1, 31, 14, 30, 0).expect("Invalid DateTime");

// Using slashes with numeric month
println!("{}", dt.format_standard());
// Output: 31/01/2026

// Using dashes with numeric month
println!("{}", dt.format_standard_dash());
// Output: 31-01-2026

// Using dashes with Lao month name
println!("{}", dt.format_lao_month_dash());
// Output: 31-ມັງກອນ-2026

// Using slashes with Lao month name
println!("{}", dt.format_lao_month_slash());
// Output: 31/ມັງກອນ/2026

Full Lao Date Format

use Lao_date_format::LaoDateTime;

let dt = LaoDateTime::new(2024, 3, 27, 14, 30, 0).expect("Invalid DateTime");
println!("{}", dt.format_lao_full());
// Output: ວັນພຸດ ທີ ໒໗ ເດືອນມີນາ ປີ ໒໕໖໗

Short Lao Date Format (Buddhist Era)

use Lao_date_format::LaoDateTime;

let dt = LaoDateTime::new(2024, 3, 27, 14, 30, 0).expect("Invalid DateTime");
println!("{}", dt.format_lao_short());
// Output: ໒໗/໓/໒໕໖໗

Lao Time Format

use Lao_date_format::LaoDateTime;

let dt = LaoDateTime::new(2024, 3, 27, 14, 30, 5).expect("Invalid DateTime");
println!("{}", dt.format_lao_time());
// Output: ໑໔:໓໐:໐໕

Parsing Lao Dates

You can parse Lao date strings (in DD/MM/YYYY_BE format) back into LaoDateTime objects.

use Lao_date_format::{parse_lao_date, LaoDateTime};

let date_str_lao = "໒໗/໓/໒໕໖໗";
let dt_lao = parse_lao_date(date_str_lao).expect("Failed to parse Lao date");
// Output: LaoDateTime { year: 2024, month: 3, day: 27, ... }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages