Date command lformat substitution operators, me totally out

A forum for general AmigaOS 4.x support questions that are not platform-specific
mlehto
Posts: 54
Joined: Thu Jun 23, 2011 12:39 pm

Date command lformat substitution operators, me totally out

Post by mlehto »

lformat and possible bugs.

My system is Peg2/1gb/Radeon9250. This is made with normal amiga shell.

I used DATE command lformat substitution operators from http://www.titan.co.nz/amigaak/AA020844e2D.htm

Pretty amazing site... loads of useful information.


I renamed file qwe with next command set: rename qwe qwe.`date lformat %operator`

Im finetuning my backup logs, so find these.

Most operators works fine, some not.

%a works
%A works
%b works
%B works

%c fails,
3.RAM Disk:> rename qwe qwe.`date lformat %c`
RENAME: Destination "2014" is not a directory.

If I try to point comman to directory, result is similar.

%d works

%D fails,
3.RAM Disk:> rename qwe qwe.`date lformat %D`
RENAME: Can't rename "qwe" as "qwe.02/06/14" because
RENAME: object not found


%e fails,
3.RAM Disk:> rename qwe qwe.`date lformat %e`
RENAME: Destination "6" is not a directory.

%h works
%H works
%I works
%j works
%m works
%n works
%p works
%q works
%Q works

%r fails
3.RAM Disk:> rename qwe qwe.`date lformat %r`
RENAME: Destination "PM" is not a directory.

%R fails,
3.RAM Disk:> rename qwe qwe.`date lformat %R`
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:49" because
RENAME: device (or volume) is not mounted

%S works
%t works

%T fails,
3.RAM Disk:> rename qwe qwe.`date lformat %T`
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:51:22" because
RENAME: device (or volume) is not mounted

%U works

%w works, counts as monday is first day of week, documentation says that should start from sunday
%W, counts as sunday is first day of week, my documentation says that should start from monday
Either doc is wrong or output is wrong?

%x fails,
3.RAM Disk:> rename qwe qwe.`date lformat %x`
RENAME: Can't rename "qwe" as "qwe.02/06/14" because
RENAME: object not found

%X fails,
3.RAM Disk:> rename qwe qwe.`date lformat %X`
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:54:28" because
RENAME: device (or volume) is not mounted

%y works
%Y works

There seems to be three different misbehaving.

1st

Operator %c
RENAME: Destination "2014" is not a directory.

Operator %e
RENAME: Destination "6" is not a directory.

Operator %r
RENAME: Destination "PM" is not a directory.

%c - same as "%a %b %d %H:%M:%S %Y"
%e - day number with leading spaces
%r - same as "%I:%M:%S %p"


2nd

Operator %D
RENAME: Can't rename "qwe" as "qwe.02/06/14" because
RENAME: object not found

Operator %x
RENAME: Can't rename "qwe" as "qwe.02/06/14" because
RENAME: object not found

%D - same as "%m/%d/%y"
%x - same as "%m/%d/%y"


3rd

Operator %R
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:49" because
RENAME: device (or volume) is not mounted

Operator %T
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:51:22" because
RENAME: device (or volume) is not mounted

Operator %X
Amigados requester, Please insert volume qwe.23 in any drive Proess: 954 "rename"
RENAME: Can't rename "qwe" as "qwe.23:54:28" because
RENAME: device (or volume) is not mounted

%R - same as "%H:%M"
%T - same as "%H:%M:%S"
%X - same as "%H:%M:%S"


Could someone from betatesting team test and confirm ?

Thanks.
Last edited by mlehto on Fri Feb 07, 2014 5:01 pm, edited 1 time in total.

mlehto
Posts: 54
Joined: Thu Jun 23, 2011 12:39 pm

Re: Date command lformat substitution operators bugs

Post by mlehto »

Additionally, can someone tell, where I get these `` marks around date lformat from finnish/swedish pc-keyboard. I'm bit tired to copypaste them ... :(

User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 521
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Date command lformat substitution operators bugs

Post by LyleHaze »

mlehto wrote:Additionally, can someone tell, where I get these `` marks around date lformat from finnish/swedish pc-keyboard. I'm bit tired to copypaste them ... :(
On a US keyboard, it's the key to the left of the '1', top row, just below ESC

On to what some patterns work in a rename and some do not.

When you use the back-apostrophe in a command, it runs whatever is inside those apostrophes, and inserts the output into your command line.

Let me demonstrate here.
RAM Disk:> date lformat %A
Thursday

Now using your example, if I type
rename foo foo.`date lformat %A`

Then the shell runs `date lformat %A`, and gets the output "Thursday".
It is now ready to run the rename command, and the result is just like
you had just typed
rename foo foo.Thursday
Because Thursday is the result of `date lformat %A`

Now let's look at some that do NOT work.
Your original post says %c fails.

Let's try it alone before we add it to rename:
RAM Disk:> date lformat %c
Thu Feb 06 22:38:08 2014

So if I tried to
rename foo foo.`date lformat %c`

What I am really asking is for
rename foo foo.Thu Feb 06 22:38:08 2014

Which is not a legal filename, because it has too many colons.
Remember, Colons are reserved as a separator between drive and directories.
So you are asking for an illegal rename, and it fails.
A few others that you say don't work include:
%D %e %r %R %T %x %X

Now if you try each of those, I'll bet that you're getting colons, slashes, or other formats
that are illegal in filenames..

I hope it makes a bit more sense now.
:)
LyleHaze

User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 521
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Date command lformat substitution operators bugs

Post by salass00 »

mlehto wrote:Additionally, can someone tell, where I get these `` marks around date lformat from finnish/swedish pc-keyboard. I'm bit tired to copypaste them ... :(
On Finnish PC keyboard it's SHIFT and the key just to the left of the backspace key. Since it's a dead key you have to press SPACE afterwards to produce the character. Also FWIW the Finnish keymap in AmigaOS 4.x doesn't work very well for any of my Finnish keyboards so I use the Swedish keymap instead which works better.

User avatar
LyleHaze
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 521
Joined: Sat Jun 18, 2011 4:06 pm
Location: North Florida, near the Big Bend

Re: Date command lformat substitution operators bugs

Post by LyleHaze »

salass00 wrote: Also FWIW the Finnish keymap in AmigaOS 4.x doesn't work very well for ...
Maybe it's not "Finnished"?
Sorry, I couldn't resist. :roll:

User avatar
gazelle
Posts: 102
Joined: Sun Mar 04, 2012 12:49 pm
Location: Frohnleiten, Austria

Re: Date command lformat substitution operators bugs

Post by gazelle »

@mletho:

I think LyleHaze pretty much explained very well where you were going wrong.

@salass00:

You do know the new keymap files are text-based? You can edit them to suit your needs.

mlehto
Posts: 54
Joined: Thu Jun 23, 2011 12:39 pm

Re: Date command lformat substitution operators bugs

Post by mlehto »

Uhhh.... at least I managed to change topic.


Thanks. Tells me, that dont post thing tired :)

Explanation was clear, I just try to add %T ...
LyleHaze wrote:
mlehto wrote:Additionally, can someone tell, where I get these `` marks around date lformat from finnish/swedish pc-keyboard. I'm bit tired to copypaste them ... :(
On a US keyboard, it's the key to the left of the '1', top row, just below ESC

On to what some patterns work in a rename and some do not.

When you use the back-apostrophe in a command, it runs whatever is inside those apostrophes, and inserts the output into your command line.

Let me demonstrate here.
RAM Disk:> date lformat %A
Thursday

Now using your example, if I type
rename foo foo.`date lformat %A`

Then the shell runs `date lformat %A`, and gets the output "Thursday".
It is now ready to run the rename command, and the result is just like
you had just typed
rename foo foo.Thursday
Because Thursday is the result of `date lformat %A`

Now let's look at some that do NOT work.
Your original post says %c fails.

Let's try it alone before we add it to rename:
RAM Disk:> date lformat %c
Thu Feb 06 22:38:08 2014

So if I tried to
rename foo foo.`date lformat %c`

What I am really asking is for
rename foo foo.Thu Feb 06 22:38:08 2014

Which is not a legal filename, because it has too many colons.
Remember, Colons are reserved as a separator between drive and directories.
So you are asking for an illegal rename, and it fails.
A few others that you say don't work include:
%D %e %r %R %T %x %X

Now if you try each of those, I'll bet that you're getting colons, slashes, or other formats
that are illegal in filenames..

I hope it makes a bit more sense now.
:)
LyleHaze

mlehto
Posts: 54
Joined: Thu Jun 23, 2011 12:39 pm

Re: Date command lformat substitution operators bugs

Post by mlehto »

Ok, I have dead key. This is pretty finished kbd, loads of typos because just dont work. waiting new atm. Actually A4k original, hopefully works better.

Switched to swedish keyboard map.
salass00 wrote:
mlehto wrote:Additionally, can someone tell, where I get these `` marks around date lformat from finnish/swedish pc-keyboard. I'm bit tired to copypaste them ... :(
On Finnish PC keyboard it's SHIFT and the key just to the left of the backspace key. Since it's a dead key you have to press SPACE afterwards to produce the character. Also FWIW the Finnish keymap in AmigaOS 4.x doesn't work very well for any of my Finnish keyboards so I use the Swedish keymap instead which works better.

User avatar
gazelle
Posts: 102
Joined: Sun Mar 04, 2012 12:49 pm
Location: Frohnleiten, Austria

Re: Date command lformat substitution operators bugs

Post by gazelle »

mlehto wrote:Explanation was clear, I just try to add %T ...
You can't use %T because it contains colons ":" which should not be used in filenames.

Use "%H%M%S" or "%H_%M_%S" or "%H-%M-%S" or ...

mlehto
Posts: 54
Joined: Thu Jun 23, 2011 12:39 pm

Re: Date command lformat substitution operators, me totally

Post by mlehto »

@Gazelle

Huh,

When I now read my answer to LyleHaze, it is pretty crappy english, even from me...

What I meant:

Explanation was clear, thank you.

I try (tried?) to add %T to my scrip and it drove me troubles. Then I started to test things and my assumption drove me even deeper troubles. Then, when situation wasnt enought problematic and embarassing I continue to drive myself even deeper pithole using overshorted and bad english, and thereafter no-one didn't understand, what I mean. Not even myself.

Thanks everybody

I go to take english lessons :)

And next time I keep in mind, that if someone gives good explanation to me, he deserve better and undestandable language. Thanks Lyle :)

Overall this lformat is damn fine addition. I'm not very good in AmigaDos but it make it just more intresting. Somehow I understood it uncorrectly. I thought that it is general command, wich is universally same everywhere, but it is more flexible, and syntax depends, how or where it is used.

Post Reply