[Home] [Downloads] [Search] [Help/forum]

os.setlocale

Summary

Sets the current locale to the supplied locale

Prototype

name = os.setlocale (locale, category)


Description

Sets the current locale to the supplied locale. Category, which is optional, is a string which is one of:


  • "all" (the default)
  • "collate"
  • "ctype"
  • "monetory"
  • "numeric"
  • "time"


Returns the name of the new locale, or nil if invalid.


print (os.setlocale ("en", "collate")) --> English_United States.1252


Hint: I found that in Australia, the default in Lua was to use the USA time format (MM/DD/YY) rather than the local format (DD/MM/YY) when displaying dates with os.date. This line seemed to fix that:


print (os.setlocale ("", "time")) --> English_Australia.1252


According to the help file "If locale points to an empty string, the locale is the implementation-defined native environment.". Thus the empty locale string seemed take the country default.


See Also ...

Lua functions

os.clock - Amount of elapsed/CPU time used (depending on OS)
os.date - Formats a date/time string
os.difftime - Calculates a time difference in seconds
os.execute - Executes an operating system command
os.exit - Attempts to terminate the process
os.getenv - Returns an operating system environment variable
os.remove - Deletes a file
os.rename - Renames a file
os.time - Returns the current time or calculates the time in seconds from a table
os.tmpname - Returns a name for a temporary file

Topics

Lua base functions
Lua bc (big number) functions
Lua bit manipulation functions
Lua coroutine functions
Lua debug functions
Lua io functions
Lua math functions
Lua os functions
Lua package functions
Lua PCRE regular expression functions
Lua script extensions
Lua string functions
Lua syntax
Lua table functions
Lua utilities
Scripting
Scripting callbacks - plugins

(Help topic: lua=os.setlocale)

Documentation contents page


Search ...

Enter a search string to find matching documentation.

Search for:   

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]