How to translate text returned from Date::fuzzy_span that is used in Kohana 3.3.1? from
"a couple of days ago"
"less than a week ago"
to another language using i18n files.
Put all possible strings from the documentation in a translation file.
Next you only have to do something like this.
echo __(Date::fuzzy_span(time() + 20));
Related
I'm literally confused how to make the XPATH in DataStage, because i've tried some things from Google and that gave me no hope or whatsoever.
What i wanted is something like this :
<redcords ACCOUNT_NO="1020006187840" BALANCE="0" BALANCE_IDR="0" CIF="1520001183600" CURRENCY="JPY " CURRRATE="1" CUSTOMER_ID="ETL" OPENING_DATE="22/01/2014" PRODUCT_TYPE="ZJPY " RATE="131.2" REKENING="31/07/2019" STATUS="7000299383" UPDATED_BY="0" UPDATED_DATE="7000299383"/>
I mean like where can i configure this XML Format in XPATH? And customized it as i wanted to?
I'd like to format a date with the quarter and year, e.g.
Q1 2018
Is there any way to do this using strftime or I18n.l? I can't see anything RE quarters in the docs.
I've been doing
month = datum.recorded_at.month - 1
quarter = (month / 3) + 1
"Q#{quarter} #{datum.recorded_at.strftime('%y')}"
But this is not a good approach because it can't easily be localised (e.g. some of our white label partners might want to format dates differently rather than using quarters)
It sounds like you already know how to calculate the quarter, but you're not sure how to organize your code to allow for flexible formatting without hardcoding a particular format that uses quarters.
What you need is for strftime to have a "formatting directive" for quarters (e.g. %q)
You could override strftime to add a new directive, but generally it's best to avoid overriding such things.
Instead I'd recommend defining your own formatting module that understands %q and piggybacks on strftime for everything else:
module MyDateFormatter
def self.format_date(date, format)
quarter = get_quarter(date)
date.strftime(format.gsub("%q", "Q#{quarter}"))
end
def self.get_quarter(date)
# Put whatever quarter calculation you want to use here
end
end
Clients who want to use quarters can have a format string that includes your special %q directive, whereas clients who don't want quarters can have a format string that doesn't use %q.
I am trying to write a cucumber test for a page that includes a datepicker. I swear this was working yesterday, but not so much today.
Then(/^select date (\d+) day(?:s|) prior to today$/) do |n|
day=Date.today-(n.to_i)
target = Date.strptime("#{day}",'%Y-%m-%d')
target_month_year = target.strftime('%B %Y')
selected_month_year = (find('.datepicker-switch').native.text)
unless target_month_year == selected_month_year
find('.prev').click
sleep 1
end
find('.day', :text => "#{day.day}", match: :prefer_exact).click
sleep 2
end
Then I have a separate test that checks that the correct date is presented after selection. I have verified that day.day is giving me the correct result by including a puts(day.day), as well as all the other variables. I think the problem is a matching issue, today's date is 04/24/2015 and I selecting 15 days prior. So the datepicker that displays the month and year above and allows you to select previous or next, then the days shown are according to how many days in that particular month. and a few day before and after. the days for the previous month are class="old day" and the ones for the month displayed are class="day" and for the next month class="new day". so the month I want is april and the day is the ninth. it keeps selecting the 29th of march. which is the first day listed on the page that contains a "9". but the class is wrong, since I want "day" not "old day" and the day is wrong because I want "9" not "29" I even put in a :prefer_exact because that has fixed matching the wrong element in the past for me.
Not sure what to try next. Any advice greatly appreciated.
cucumber 1.3.10
capybara 2.4.1
ruby 1.9.3p551
Ideally, don't select by text if you can avoid it.
But in this case try using a regex instead of just plain text.
find('.day', :text => Regexp.new("^#{day.day}$"), match: :prefer_exact).click
There's a little related reading at the end of this (currently unimplemented) issue: https://github.com/jnicklas/capybara/issues/1256
I'm trying to use a relatively basic IF function but having no luck - i'm sure i just have brackets or parenthesis wrong or something. Reckon it will be childsplay for you guys....
The formula is intended to show how many days a date has passed by. Date is shown in T column.
Basically it was working fine as the following, both for pending and past dates:
=IF(T7<=TODAY(), (TODAY()-T7),-(T7-TODAY()))
But I got greedy and wanted it to return more of a statement when the date has passed, as to how much it has passed by. So I've tried to make this happen with:
=IF(T7<=TODAY(),"EffOut(TODAY()-T7) days ago",-(T7-TODAY()))
Hoping it would enter "EffOut 8 days ago" (when TODAY()-T7 is 8 days) for example.
But it doesnt - it shows the entire argument i.e "EffOut(TODAY()-T7) days ago" in the return cell.
Is it possible to have a kind of embedded formula in the 'value_if' fields, mixed with text in this sense?
Happy to share the document if that would help, but will need to clear the data first so just let me know.
Thanks in advance, any help is much appreciated! Having read other posts I think it will just be a simple fix but its well beyond me! (I only got this far by perusing forums...)
Maybe something like this...
=IF(T7<=TODAY(),"EffOut "&DAYS(TODAY(),T7)&" days ago",-(T7-TODAY()))
=IF(T7<=TODAY(),"EffOut "&(TODAY()-T7)&" days ago",-(T7-TODAY()))
You just need to be careful to put "" around any strings. This is how Excel knows that's not a part of the formula. Remember to out the spaces is to the string like I did above so it looks like a sentence. The & sign combines the results of the calculated parts and the strings.
right now, I have a date that is displayed like this:
19\06\2013
what I want is this :
19\6\2013
my current smarty code is :
{$variable|date_format:"%e\%m\%Y"}
I tried using %n for the month (I assumed that anything that works on php will work in smarty) but it did not give me any result.
How can I display the month without a leading zero in Smarty? is there any workaround solutions? I do not want to edit and format the date in my php file.
Today I have the same problem and this works for me…
Windows server
This solution seems to work only on windows based servers (localhost in my case).
{$variable|date_format:"%d\%#m\%Y"}
Just put hash # before letter 'm'.
I'm using Smarty v3
Linux server:
I moved my project to remote server (probably linux) and hash sign stop to work. I found another solution, just put hyphen - before letter 'm':
{$variable|date_format:"%d\%-m\%Y"}
And this works on linux, but not on windows.
Cross-platform PHP-based solution:
But because smarty is a PHP plugin we can use all of PHP functions. So this is another solution I found, maybe not so elegant but it seems to work everywhere.
{assign var="dateTime" value=$variable|strtotime}
{*
or shorter:
{$dateTime=$variable|strtotime}
*}
<p>{"j/n/Y"|date:$dateTime}</p>
Note:
The above solutions work for formatting day with out leading zero also:
{$variable|date_format:"%-d vs %d vs %#d"}
{$variable|date_format:"j. n. Y":"":"any string - not either strftime or auto"}
then you can write date format as in php function date().
smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto')