File: README.md

package info (click to toggle)
libposix-strftime-compiler-perl 0.40-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 156 kB
  • ctags: 15
  • sloc: perl: 431; makefile: 2
file content (82 lines) | stat: -rw-r--r-- 2,767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
[![Build Status](https://travis-ci.org/kazeburo/POSIX-strftime-Compiler.png?branch=master)](https://travis-ci.org/kazeburo/POSIX-strftime-Compiler)
# NAME

POSIX::strftime::Compiler - GNU C library compatible strftime for loggers and servers

# SYNOPSIS

    use POSIX::strftime::Compiler qw/strftime/;

    say strftime('%a, %d %b %Y %T %z',localtime):
    
    my $psc = POSIX::strftime::Compiler->new($fmt);
    say $psc->to_string(localtime);

# DESCRIPTION

POSIX::strftime::Compiler provides GNU C library compatible strftime(3). But this module will not affected
by the system locale.  This feature is useful when you want to write loggers, servers and portable applications.

For generate same result strings on any locale, POSIX::strftime::Compiler wraps POSIX::strftime and 
converts some format characters to perl code

# FUNCTION

- strftime($fmt:String, @time)

    Generate formatted string from a format and time.

        my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
        strftime('%d/%b/%Y:%T %z',$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst):

    Compiled codes are stored in `%POSIX::strftime::Compiler::STRFTIME`. This function is not exported by default.

# METHODS

- new($fmt)

    create instance of POSIX::strftime::Compiler

- to\_string(@time)

    Generate formatted string from time.

# FORMAT CHARACTERS

POSIX::strftime::Compiler supports almost all characters that GNU strftime(3) supports. 
But `%E[cCxXyY]` and `%O[deHImMSuUVwWy]` are not supported, just remove E and O prefix.

# A RECOMMEND MODULE

- [Time::TZOffset](https://metacpan.org/pod/Time::TZOffset)

    If [Time::TZOffset](https://metacpan.org/pod/Time::TZOffset) is available, P::s::Compiler use it for more faster time zone offset calculation.
    I strongly recommend you to install this if you use `%z`.

# PERFORMANCE ISSUES ON WINDOWS

Windows and Cygwin and some system may not support `%z` and `%Z`. For these system, 
POSIX::strftime::Compiler calculate time zone offset and find zone name. This is not fast.
If you need performance on Windows and Cygwin, please install [Time::TZOffset](https://metacpan.org/pod/Time::TZOffset)

# SEE ALSO

- [POSIX::strftime::GNU](https://metacpan.org/pod/POSIX::strftime::GNU)

    POSIX::strftime::Compiler is built on POSIX::strftime::GNU::PP code

- [POSIX](https://metacpan.org/pod/POSIX)
- [Apache::LogFormat::Compiler](https://metacpan.org/pod/Apache::LogFormat::Compiler)

# LICENSE

Copyright (C) Masahiro Nagano.

Format specification is based on strftime(3) manual page which is a part of the Linux man-pages project.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

# AUTHOR

Masahiro Nagano <kazeburo@gmail.com>